mdn.go-v.org

`javascript` error code

The JavaScript error is a WebDriver error that occurs when a script the supplied by the user fails to execute.

source: MDN Web Docslicence: CC BY-SA 2.5+ (MDN)database: /home/dbs/mdn.dbmode: tablerecords: 14753 (max_rowid)citation: https://developer.mozilla.org/

The JavaScript error is a WebDriver error that occurs when a script the supplied by the user fails to execute.

Full text

The **JavaScript** error is a [WebDriver error](/docs/Web/WebDriver/Reference/Errors) that occurs when a script the supplied by the user fails to execute.

The underlying cause of the execution error is often supplied in the error message, along with a stacktrace provided by the JavaScript engine in the browser.

## Example

Consider the following injected script which tries to use an undefined variable. In JavaScript this normally causes a ReferenceError to be thrown. WebDriver catches this error and serializes it as a JavaScript error:

```python
from selenium import webdriver
from selenium.common import exceptions

session = webdriver.Firefox()
try:
session.execute_script("return foo")
except exceptions.JavascriptException as e:
print(e.message)
```

Output:

```plain
JavascriptException: ReferenceError: foo is not defined
```

## See also

- [List of WebDriver errors](/docs/Web/WebDriver/Reference/Errors)
- Associated commands:
- [Execute Script](/docs/Web/WebDriver/Reference/Commands/ExecuteScript)
- [Execute Async Script](/docs/Web/WebDriver/Reference/Commands/ExecuteAsyncScript)

Fields

page_typewebdriver-error
tags
source: MDN Web Docslicence: CC BY-SA 2.5+ (MDN)year: —id: Web/WebDriver/Reference/Errors/JavaScriptErrorcitation: https://developer.mozilla.org/en-US/docs/Web/WebDriver/Reference/Errors/JavaScriptError

JSON · full text · full-text JSON

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.