# encoding: utf-8## Licensed to the Software Freedom Conservancy (SFC) under one# or more contributor license agreements. See the NOTICE file# distributed with this work for additional information# regarding copyright ownership. The SFC licenses this file# to you under the Apache License, Version 2.0 (the# "License"); you may not use this file except in compliance# with the License. You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing,# software distributed under the License is distributed on an# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY# KIND, either express or implied. See the License for the# specific language governing permissions and limitations# under the License.moduleSeleniummoduleWebDrivermoduleErrorclassWebDriverError<StandardError;endclassUnsupportedOperationError<WebDriverError;endclassIndexOutOfBoundsError<WebDriverError;end# 1classNoCollectionError<WebDriverError;end# 2classNoStringError<WebDriverError;end# 3classNoStringLengthError<WebDriverError;end# 4classNoStringWrapperError<WebDriverError;end# 5classNoSuchDriverError<WebDriverError;end# 6## An element could not be located on the page using the given search# parameters.#classNoSuchElementError<WebDriverError;end# 7## A request to switch to a frame could not be satisfied because the# frame could not be found.#classNoSuchFrameError<WebDriverError;end# 8classUnknownCommandError<WebDriverError;end# 9## Indicates that a reference to an element is now "stale" - the element# no longer appears in the DOM of the page.#classStaleElementReferenceError<WebDriverError;end# 10## Raised to indicate that although an element is present on the DOM,# it is not visible, and so is not able to be interacted with.#classElementNotVisibleError<WebDriverError;end# 11## Raised when an interaction could not be performed because the element# is in an invalid state (e.g. attempting to click a disabled element).#classInvalidElementStateError<WebDriverError;end# 12## An unknown server-side error occurred while processing the command.#classUnknownError<WebDriverError;end# 13classExpectedError<WebDriverError;end# 14## An attempt was made to select an element that cannot be selected.#classElementNotSelectableError<WebDriverError;end# 15classNoSuchDocumentError<WebDriverError;end# 16## An error occurred while executing user supplied JavaScript.#classJavascriptError<WebDriverError;end# 17classNoScriptResultError<WebDriverError;end# 18## An error occurred while searching for an element by XPath.#classXPathLookupError<WebDriverError;end# 19classNoSuchCollectionError<WebDriverError;end# 20## Raised when a command does not complete in enough time.#classTimeOutError<WebDriverError;end# 21classNullPointerError<WebDriverError;end# 22classNoSuchWindowError<WebDriverError;end# 23## Raised when attempting to add a cookie under a different domain than# the current URL.#classInvalidCookieDomainError<WebDriverError;end# 24## Raised when a driver fails to set a cookie.#classUnableToSetCookieError<WebDriverError;end# 25## Raised when an alert dialog is present that has not been dealt with.#classUnhandledAlertError<WebDriverError;end# 26## Indicates that a user has tried to access an alert when one is not present.#classNoAlertPresentError<WebDriverError;end# 27## A script did not complete before its timeout expired.#classScriptTimeOutError<WebDriverError;end# 28## The coordinates provided to an interactions operation are invalid.#classInvalidElementCoordinatesError<WebDriverError;end# 29## Indicates that IME support is not available. This exception is rasied# for every IME-related method call if IME support is not available on# the machine.#classIMENotAvailableError<WebDriverError;end# 30## Indicates that activating an IME engine has failed.#classIMEEngineActivationFailedError<WebDriverError;end# 31## Argument was an invalid selector (e.g. XPath/CSS).#classInvalidSelectorError<WebDriverError;end# 32## A new session could not be created.#classSessionNotCreatedError<WebDriverError;end# 33## Indicates that the target provided to the actions #move method is# invalid, e.g. outside of the bounds of the window.#classMoveTargetOutOfBoundsError<WebDriverError;end# 34# @api privateERRORS=[IndexOutOfBoundsError,# 1NoCollectionError,# 2NoStringError,# 3NoStringLengthError,# 4NoStringWrapperError,# 5NoSuchDriverError,# 6NoSuchElementError,# 7NoSuchFrameError,# 8UnknownCommandError,# 9StaleElementReferenceError,# 10ElementNotVisibleError,# 11InvalidElementStateError,# 12UnknownError,# 13ExpectedError,# 14ElementNotSelectableError,# 15NoSuchDocumentError,# 16JavascriptError,# 17NoScriptResultError,# 18XPathLookupError,# 19NoSuchCollectionError,# 20TimeOutError,# 21NullPointerError,# 22NoSuchWindowError,# 23InvalidCookieDomainError,# 24UnableToSetCookieError,# 25UnhandledAlertError,# 26NoAlertPresentError,# 27ScriptTimeOutError,# 28InvalidElementCoordinatesError,# 29IMENotAvailableError,# 30IMEEngineActivationFailedError,# 31InvalidSelectorError,# 32SessionNotCreatedError,# 33MoveTargetOutOfBoundsError# 34].freezeclass<<selfdeffor_code(code)returnif[nil,0].include?codereturnERRORS[code-1]ifcode.is_a?Integerklass_name=code.split(' ').map(&:capitalize).joinError.const_get("#{klass_name.gsub('Error','')}Error")rescueNameErrorWebDriverErrorendendend# Errorend# WebDriverend# Selenium