Module: Selenium::WebDriver::Error

Defined in:
lib/selenium/webdriver/common/error.rb,
lib/selenium/webdriver/common/w3c_error.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, JavascriptError, MoveTargetOutOfBoundsError, NoAlertPresentError, NoCollectionError, NoScriptResultError, NoStringError, NoStringLengthError, NoStringWrapperError, NoSuchAlertError, NoSuchCollectionError, NoSuchDocumentError, NoSuchDriverError, NoSuchElementError, NoSuchFrameError, NoSuchWindowError, NullPointerError, ScriptTimeOutError, ScriptTimeoutError, ServerError, SessionNotCreatedError, StaleElementReferenceError, TimeOutError, TimeoutError, UnableToCaptureScreenError, UnableToSetCookieError, UnexpectedAlertOpenError, UnhandledAlertError, UnknownCommandError, UnknownError, UnknownMethodError, UnsupportedOperationError, WebDriverError, XPathLookupError

Constant Summary collapse

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.

[
  IndexOutOfBoundsError,          # 1
  NoCollectionError,              # 2
  NoStringError,                  # 3
  NoStringLengthError,            # 4
  NoStringWrapperError,           # 5
  NoSuchDriverError,              # 6
  NoSuchElementError,             # 7
  NoSuchFrameError,               # 8
  UnknownCommandError,            # 9
  StaleElementReferenceError,     # 10
  ElementNotVisibleError,         # 11
  InvalidElementStateError,       # 12
  UnknownError,                   # 13
  ExpectedError,                  # 14
  ElementNotSelectableError,      # 15
  NoSuchDocumentError,            # 16
  JavascriptError,                # 17
  NoScriptResultError,            # 18
  XPathLookupError,               # 19
  NoSuchCollectionError,          # 20
  TimeOutError,                   # 21
  NullPointerError,               # 22
  NoSuchWindowError,              # 23
  InvalidCookieDomainError,       # 24
  UnableToSetCookieError,         # 25
  UnhandledAlertError,            # 26
  NoAlertPresentError,            # 27
  ScriptTimeOutError,             # 28
  InvalidElementCoordinatesError, # 29
  IMENotAvailableError,           # 30
  IMEEngineActivationFailedError, # 31
  InvalidSelectorError,           # 32
  SessionNotCreatedError,         # 33
  MoveTargetOutOfBoundsError      # 34
].freeze
ObsoleteElementError =
StaleElementReferenceError
UnhandledError =
UnknownError
UnexpectedJavascriptError =
JavascriptError
NoAlertOpenError =
NoAlertPresentError
ElementNotDisplayedError =
ElementNotVisibleError

Class Method Summary collapse

Class Method Details

.for_code(code) ⇒ Object


213
214
215
216
217
218
219
220
221
# File 'lib/selenium/webdriver/common/error.rb', line 213

def for_code(code)
  return if [nil, 0].include? code
  return ERRORS[code - 1] if code.is_a? Integer

  klass_name = code.split(' ').map(&:capitalize).join
  Error.const_get("#{klass_name.gsub('Error', '')}Error")
rescue NameError
  WebDriverError
end