Si potrebbe inoltre incaricare Capybara di non ignorare gli elementi nascosti a livello globale nella vostra spec_helper.rb
o equivalente. Il comportamento predefinito può essere sovrascritto:
# default behavior for hidden elements
# Capybara.ignore_hidden_elements = false
# find all elements (hidden or visible)
page.all(".articles .article[id='foo']")
# find visible elements only (overwrite the standard behavior just for this query)
page.all(".articles .article[id='foo']", :visible => true)
# changing the default behavior (e.g. in your features/support/env.rb file)
Capybara.ignore_hidden_elements = true
# now the query just finds visible nodes by default
page.all(".articles .article[id='foo']")
# but you can change the default behaviour by passing the :visible option again
page.all(".articles .article[id='foo']", :visible => false)
esempi tratti da this article.
Grazie, ho finito con il seguente 'elem = page.find_by_id ('my_element_id'); elem.value.should eq Date.today.to_s' –
Ho anche usato ['find_by_id'] (http://rubydoc.info/github/jnicklas/capybara/master/Capybara/Node/Finders:find_by_id):' assert_equal photo .updated_at.to_datetime.to_s, page.find_by_id ('hidden_field_photo_updated_at'). value.to_datetime.to_s' – user664833