Module: SeleniumRecord::Waits::ClassMethods

Defined in:
lib/selenium_record/waits.rb

Overview

Utilities for waiting methods

Instance Method Summary collapse

Instance Method Details

#js_inactive_scriptString

Returns the string containing javascript code to be evaluated to check if there are ajax calls pending.

Returns:

  • (String)

    the string containing javascript code to be evaluated to check if there are ajax calls pending



93
94
95
96
97
# File 'lib/selenium_record/waits.rb', line 93

def js_inactive_script
  {
    jquery: 'return $.active'
  }[Configuration.js_library]
end

#seconds_for(opts) ⇒ Object



99
100
101
102
103
# File 'lib/selenium_record/waits.rb', line 99

def seconds_for(opts)
  seconds = opts[:seconds]
  return seconds if seconds
  20
end

#wait_for(seconds = DEFAULT_WAITING_TIME) ⇒ Object

Wait selenium execution until a condition take place

Parameters:

  • seconds (Integer) (defaults to: DEFAULT_WAITING_TIME)

    number of seconds to wait

Yield Returns:

  • (Boolean)

    marks whether the condition we are waiting for passes

Raises:

  • (Selenium::WebDriver::Error::TimeOutError)

    if the precondition we are waiting for doesn’t take place after completing the wait period



87
88
89
# File 'lib/selenium_record/waits.rb', line 87

def wait_for(seconds = DEFAULT_WAITING_TIME)
  Selenium::WebDriver::Wait.new(timeout: seconds).until { yield }
end