Class: Capybara::Lockstep::Client::Cuprite

Inherits:
Capybara::Lockstep::Client show all
Defined in:
lib/capybara-lockstep/client/cuprite.rb

Constant Summary

Constants inherited from Capybara::Lockstep::Client

ERROR_ALERT_OPEN, ERROR_NAVIGATED_AWAY, ERROR_PAGE_MISSING, ERROR_SNIPPET_MISSING, ERROR_WINDOW_CLOSED, SYNCHRONIZED_IVAR

Instance Method Summary collapse

Methods inherited from Capybara::Lockstep::Client

#synchronize, #synchronized=, #synchronized?

Methods included from PageAccess

#alert_present?, #page, #supported_driver?

Methods included from Logging

#log

Instance Method Details

#with_synchronization_error_handlingObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/capybara-lockstep/client/cuprite.rb', line 5

def with_synchronization_error_handling
  yield

rescue ::Ferrum::ScriptTimeoutError
  timeout_message = "Could not synchronize client within #{timeout} seconds"
  log timeout_message
  if timeout_with == :error
    raise Timeout, timeout_message
  else
    # Don't raise an error, this may happen if the server is slow to respond.
    # We will retry on the next Capybara synchronize call.
  end

rescue ::Ferrum::JavaScriptError => e
  if e.message.include?('unload')
    log ERROR_NAVIGATED_AWAY
  else
    unhandled_synchronize_error(e)
  end

rescue ::Ferrum::BrowserError => e
  if e.message.include?('Session with given id not found.')
    log ERROR_WINDOW_CLOSED
    # Don't raise an error, this will happen in an innocent test where a click closes a window.
    # We will retry on the next Capybara synchronize call.
  else
    unhandled_synchronize_error(e)
  end
rescue StandardError => e
  unhandled_synchronize_error(e)
end