Module: EDSL::PageObject::AJAX

Included in:
Page, Section
Defined in:
lib/edsl/page_object/ajax_support.rb

Instance Method Summary collapse

Instance Method Details

#wait_for_ajax(timeout = 30, message = nil) ⇒ Object

Wait until there are no pending ajax requests. This requires you to set the javascript framework in advance.

the timeout duration.

Parameters:

  • the (Numeric)

    amount of time to wait for the block to return true.

  • the (String)

    message to include with the error if we exceed



89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/edsl/page_object/ajax_support.rb', line 89

def wait_for_ajax(timeout = 30, message = nil)
  end_time = ::Time.now + timeout
  until ::Time.now > end_time
    begin
      return if browser.execute_script(::EDSL::PageObject::JavascriptFrameworkFacade.pending_requests) == 0
    rescue Selenium::WebDriver::Error::UnknownError, Selenium::WebDriver::Error::JavascriptError
    end
    sleep 0.5
  end
  message = "Timed out waiting for ajax requests to complete" unless message
  raise message
end