error module

error.isError(val)

Check if val is an instance of the Error prototype.

Because error objects may originate from different globals, comparing the prototype of the left hand side with the prototype property from the right hand side, which is what instanceof does, will not work. If the LHS and RHS come from different globals, this check will always fail because the two objects will not have the same identity.

Therefore it is not safe to use instanceof in any multi-global situation, e.g. in content across multiple Window objects or anywhere in chrome scope.

This function also contains a special check if val is an XPCOM nsIException because they are special snowflakes and may indeed cause Firefox to crash if used with instanceof.

Arguments
  • val (*) – Any value that should be undergo the test for errorness.

Returns

boolean – True if error, false otherwise.

error.isWebDriverError(obj)

Checks if obj is an object in the WebDriverError() prototypal chain.

Arguments
  • obj (*) – Arbitrary object to test.

Returns

boolean – True if obj is of the WebDriverError prototype chain, false otherwise.

error.wrap(err)

Ensures error instance is a WebDriverError().

If the given error is already in the WebDriverError prototype chain, err is returned unmodified. If it is not, it is wrapped in UnknownError().

Arguments
  • err (Error) – Error to conditionally turn into a WebDriverError.

Returns

WebDriverError – If err is a WebDriverError, it is returned unmodified. Otherwise an UnknownError type is returned.

error.report()

Unhandled error reporter. Dumps the error and its stacktrace to console, and reports error to the Browser Console.

error.stringify()

Prettifies an instance of Error and its stacktrace to a string.

stack()

Create a stacktrace to the current line in the program.

class ElementClickInterceptedError(obscuredEl, coords)

An element click could not be completed because the element receiving the events is obscuring the element that was requested clicked.

Arguments
  • obscuredEl (Element) – Element obscuring the element receiving the click. Providing this is not required, but will produce a nicer error message.

  • number> coords (Map.<string,) – Original click location. Providing this is not required, but will produce a nicer error message.

class ElementNotAccessibleError(message)

The Gecko a11y API indicates that the element is not accessible.

class ElementNotInteractableError(message)

A command could not be completed because the element is not pointer- or keyboard interactable.

class InsecureCertificateError(message)

Navigation caused the user agent to hit a certificate warning, which is usually the result of an expired or invalid TLS certificate.

class InvalidArgumentError(message)

The arguments passed to a command are either invalid or malformed.

class InvalidCookieDomainError(message)

An illegal attempt was made to set a cookie under a different domain than the current page.

class InvalidElementStateError(message)

A command could not be completed because the element is in an invalid state, e.g. attempting to clear an element that isn’t both editable and resettable.

class InvalidSelectorError(message)

Argument was an invalid selector.

class InvalidSessionIDError(message)

Occurs if the given session ID is not in the list of active sessions, meaning the session either does not exist or that it’s not active.

class JavaScriptError(x)

An error occurred whilst executing JavaScript supplied by the user.

class MoveTargetOutOfBoundsError(message)

The target for mouse interaction is not in the browser’s viewport and cannot be brought into that viewport.

class NoSuchAlertError(message)

An attempt was made to operate on a modal dialog when one was not open.

class NoSuchElementError(message)

An element could not be located on the page using the given search parameters.

class NoSuchFrameError(message)

A command to switch to a frame could not be satisfied because the frame could not be found.

class NoSuchWindowError(message)

A command to switch to a window could not be satisfied because the window could not be found.

class ScriptTimeoutError(message)

A script did not complete before its timeout expired.

class SessionNotCreatedError(message)

A new session could not be created.

class StaleElementReferenceError(message)

A command failed because the referenced element is no longer attached to the DOM.

class TimeoutError(message)

An operation did not complete before its timeout expired.

class UnableToSetCookieError(message)

A command to set a cookie’s value could not be satisfied.

class UnexpectedAlertOpenError(message)

A modal dialog was open, blocking this operation.

class UnknownCommandError(message)

A command could not be executed because the remote end is not aware of it.

class UnknownError(message)

An unknown error occurred in the remote end while processing the command.

class UnsupportedOperationError(message)

Indicates that a command that should have executed properly cannot be supported for some reason.

class WebDriverError(x)

WebDriverError is the prototypal parent of all WebDriver errors. It should not be used directly, as it does not correspond to a real error in the specification.

Arguments
  • x (string|Error) – Optional string describing error situation or Error instance to propagate.