Any WebDriver command that is sent to might plausibly receive an error response. An error is represented by an HTTP response with an HTTP status code in the 4xx or 5xx range, and a JSON payload holding details of the error.
PayloadThe error object is a JSON Object that bears three, and sometimes four, fields:
error
Error type.
message
Human-readable description of the nature of the error.
stacktrace
Stacktrace report of the active stack frames at the time when the error occurred.
data
(optional)
Arbitrary and implementation-defined data that it can be useful to present the user with.
Many drivers include the user prompt's text when encountering an unexpected alert open error.
For example a GET
request to /session/1234/url
, where 1234
is a bogus session, would return a response with the 404 Not Found
status and the following body:
{
"value": {
"error": "invalid session id",
"message": "No active session with ID 1234",
"stacktrace": ""
}
}
It is optional for the driver to annotate errors with additional error data. Notably, this is common when a user prompt, such as window.alert
, has opened a modal dialog after execution of your previous WebDriver command request.
Because both WebDriver and JavaScript execution is halted by such a dialog, we see an unexpected alert open error in the subsequent response:
{
"value": {
"error": "unexpected alert open",
"message": "",
"stacktrace": "",
"data": {
"text": "Message from window.alert"
}
}
}
In most clients the error would be represented by some sort of error type or object representation. In Python it is represented as a WebDriverException
, in Node.js as a WebDriverError
, and in Java also as a WebDriverException
.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4