Method: Selenium::Client::Idiomatic#wait_for
- Defined in:
- lib/selenium/client/idiomatic.rb
#wait_for(options) ⇒ Object
Flexible wait semantics. ait is happening browser side. Useful for testing AJAX application.
-
wait :wait_for => :page # will wait for a new page to load
-
wait :wait_for => :popup, :window => ‘a window id’ # will wait for a new popup window to appear. Also selects the popup window for you provide ‘:select => true`
-
wait :wait_for => :ajax # will wait for all ajax requests to be completed using semantics of default javascript framework
-
wait :wait_for => :ajax, :javascript_framework => :jquery # will wait for all ajax requests to be completed overriding default javascript framework
-
wait :wait_for => :effects # will wait for all javascript effects to be rendered using semantics of default javascript framework
-
wait :wait_for => :effects, :javascript_framework => :prototype # will wait for all javascript effects to be rendered overriding default javascript framework
-
wait :wait_for => :element, :element => ‘new_element_id’ # will wait for an element to be present/appear
-
wait :wait_for => :no_element, :element => ‘new_element_id’ # will wait for an element to be not be present/disappear
-
wait :wait_for => :text, :text => ‘some text’ # will wait for some text to be present/appear
-
wait :wait_for => :text, :text => /A Regexp/ # will wait for some text to be present/appear
-
wait :wait_for => :text, :element => ‘a_locator’, :text => ‘some text’ # will wait for the content of ‘a_locator’ to be ‘some text’
-
wait :wait_for => :no_text, :text => ‘some text’ # will wait for the text to be not be present/disappear
-
wait :wait_for => :no_text, :text => /A Regexp/ # will wait for the text to be not be present/disappear
-
wait :wait_for => :no_text, :element => ‘a_locator’, :text => ‘some text’ # will wait for the content of ‘a_locator’ to not be ‘some text’
-
wait :wait_for => :value, :element => ‘a_locator’, :value => ‘some value’ # will wait for the field value of ‘a_locator’ to be ‘some value’
-
wait :wait_for => :no_value, :element => ‘a_locator’, :value => ‘some value’ # will wait for the field value of ‘a_locator’ to not be ‘some value’
-
wait :wait_for => :visible, :element => ‘a_locator’ # will wait for element to be visible
-
wait :wait_for => :not_visible, :element => ‘a_locator’ # will wait for element to not be visible
-
wait :wait_for => :condition, :javascript => ‘some expression’ # will wait for the javascript expression to be true
Using options you can also define an explicit timeout (:timeout_in_seconds key). Otherwise the default driver timeout is used.
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/selenium/client/idiomatic.rb', line 102 def wait_for() if [:wait_for] == :page wait_for_page [:timeout_in_seconds] elsif [:wait_for] == :ajax wait_for_ajax elsif [:wait_for] == :element wait_for_element [:element], elsif [:wait_for] == :no_element wait_for_no_element [:element], elsif [:wait_for] == :text wait_for_text [:text], elsif [:wait_for] == :no_text wait_for_no_text [:text], elsif [:wait_for] == :effects wait_for_effects elsif [:wait_for] == :popup wait_for_popup [:window], [:timeout_in_seconds] select_window [:window] if [:select] elsif [:wait_for] == :value wait_for_field_value [:element], [:value], elsif [:wait_for] == :no_value wait_for_no_field_value [:element], [:value], elsif [:wait_for] == :visible wait_for_visible [:element], elsif [:wait_for] == :not_visible wait_for_not_visible [:element], elsif [:wait_for] == :condition wait_for_condition [:javascript], [:timeout_in_seconds] end end |