तुम भी Capybara हिदायत सकता है में विश्व स्तर पर छिपा तत्वों को नजरअंदाज नहीं करने के लिए अपने spec_helper.rb
या समकक्ष। डिफ़ॉल्ट व्यवहार अधिरोहित जा सकता है:
# 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)
उदाहरण this article से लिया।
धन्यवाद, मैं निम्नलिखित 'elem = page.find_by_id (' my_element_id ') के साथ समाप्त हुआ; elem.value.should eq Date.today.to_s' –
मैंने ['find_by_id'] (http://rubydoc.info/github/jnicklas/capybara/master/Capybara/Node/Finders:find_by_id) का भी उपयोग किया:' assert_equal फोटो .updated_at.to_datetime.to_s, page.find_by_id ('hidden_field_photo_updated_at')। value.to_datetime.to_s' – user664833