Module: Seleniumrc::WaitFor
- Included in:
- SeleniumDriver, SeleniumDsl, SeleniumElement, SeleniumPage
- Defined in:
- lib/seleniumrc/wait_for.rb
Defined Under Namespace
Classes: Context
Instance Attribute Summary collapse
-
#default_timeout ⇒ Object
The default Selenium Core client side timeout.
Instance Method Summary collapse
- #default_wait_for_time ⇒ Object
- #flunk(message) ⇒ Object
- #time_class ⇒ Object
-
#wait_for(params = {}) ⇒ Object
Poll continuously for the return value of the block to be true.
Instance Attribute Details
#default_timeout ⇒ Object
The default Selenium Core client side timeout.
31 32 33 |
# File 'lib/seleniumrc/wait_for.rb', line 31 def default_timeout @default_timeout ||= 20000 end |
Instance Method Details
#default_wait_for_time ⇒ Object
22 23 24 |
# File 'lib/seleniumrc/wait_for.rb', line 22 def default_wait_for_time 5 end |
#flunk(message) ⇒ Object
36 37 38 |
# File 'lib/seleniumrc/wait_for.rb', line 36 def flunk() raise Test::Unit::AssertionFailedError, end |
#time_class ⇒ Object
26 27 28 |
# File 'lib/seleniumrc/wait_for.rb', line 26 def time_class Time end |
#wait_for(params = {}) ⇒ Object
Poll continuously for the return value of the block to be true. You can use this to assert that a client side or server side condition was met.
wait_for do
User.count == 5
end
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/seleniumrc/wait_for.rb', line 9 def wait_for(params={}) timeout = params[:timeout] || default_wait_for_time = params[:message] || "Timeout exceeded" configuration = Context.new() begin_time = time_class.now while (time_class.now - begin_time) < timeout return if yield(configuration) sleep 0.25 end flunk(configuration. + " (after #{timeout} sec)") true end |