Module: Selenium::WebDriver::Error

Defined in:
build/rb/lib/selenium/webdriver/common/error.rb,
build/rb/lib/selenium/webdriver/remote/server_error.rb

Defined Under Namespace

Classes: ElementClickInterceptedError, ElementNotInteractableError, ElementNotSelectableError, ElementNotVisibleError, ExpectedError, IMEEngineActivationFailedError, IMENotAvailableError, IndexOutOfBoundsError, InvalidArgumentError, InvalidCookieDomainError, InvalidElementCoordinatesError, InvalidElementStateError, InvalidSelectorError, InvalidSessionIdError, InvalidXpathSelectorError, InvalidXpathSelectorReturnTyperError, JavascriptError, MoveTargetOutOfBoundsError, NoAlertPresentError, NoCollectionError, NoScriptResultError, NoStringError, NoStringLengthError, NoStringWrapperError, NoSuchAlertError, NoSuchCollectionError, NoSuchCookieError, NoSuchDocumentError, NoSuchDriverError, NoSuchElementError, NoSuchFrameError, NoSuchWindowError, NullPointerError, ScriptTimeOutError, ServerError, SessionNotCreatedError, StaleElementReferenceError, TimeOutError, UnableToCaptureScreenError, UnableToSetCookieError, UnexpectedAlertOpenError, UnhandledAlertError, UnknownCommandError, UnknownError, UnknownMethodError, UnsupportedOperationError, WebDriverError, XPathLookupError

Constant Summary

ScriptTimeoutError =

Aliases for OSS dialect.

ScriptTimeOutError
TimeoutError =
TimeOutError
NoAlertOpenError =
NoAlertPresentError
ObsoleteElementError =

Aliases for backwards compatibility.

StaleElementReferenceError
UnhandledError =
UnknownError
UnexpectedJavascriptError =
JavascriptError
ElementNotDisplayedError =
ElementNotVisibleError
ERRORS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

{
  1  => IndexOutOfBoundsError,
  2  => NoCollectionError,
  3  => NoStringError,
  4  => NoStringLengthError,
  5  => NoStringWrapperError,
  6  => NoSuchDriverError,
  7  => NoSuchElementError,
  8  => NoSuchFrameError,
  9  => UnknownCommandError,
  10 => StaleElementReferenceError,
  11 => ElementNotVisibleError,
  12 => InvalidElementStateError,
  13 => UnknownError,
  14 => ExpectedError,
  15 => ElementNotSelectableError,
  16 => NoSuchDocumentError,
  17 => JavascriptError,
  18 => NoScriptResultError,
  19 => XPathLookupError,
  20 => NoSuchCollectionError,
  21 => TimeOutError,
  22 => NullPointerError,
  23 => NoSuchWindowError,
  24 => InvalidCookieDomainError,
  25 => UnableToSetCookieError,
  26 => UnhandledAlertError,
  27 => NoAlertPresentError,
  28 => ScriptTimeOutError,
  29 => InvalidElementCoordinatesError,
  30 => IMENotAvailableError,
  31 => IMEEngineActivationFailedError,
  32 => InvalidSelectorError,
  33 => SessionNotCreatedError,
  34 => MoveTargetOutOfBoundsError,
  # The following are W3C-specific errors,
  # they don't really need error codes, we just make them up!
  51 => InvalidXpathSelectorError,
  52 => InvalidXpathSelectorReturnTyperError,
  60 => ElementNotInteractableError,
  61 => InvalidArgumentError,
  62 => NoSuchCookieError,
  63 => UnableToCaptureScreenError
}.freeze

Class Method Summary collapse

Class Method Details

.for_code(code) ⇒ Object

Returns exception from code (Integer - OSS, String - W3C).

Parameters:

  • code (Integer, String, nil)


27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'build/rb/lib/selenium/webdriver/common/error.rb', line 27

def self.for_code(code)
  case code
  when nil, 0
    nil
  when Integer
    ERRORS.fetch(code)
  when String
    klass_name = code.split(' ').map(&:capitalize).join.sub(/Error$/, '')
    const_get("#{klass_name}Error", false)
  end
rescue KeyError, NameError
  WebDriverError
end