SeleniumHQ/selenium · error · WebDriverError
Unknown error: ${JSON.stringify(data)}
Error message
Unknown error: ${JSON.stringify(data)} What it means
Thrown by throwDecodedError() in error.js when the response data does not satisfy isErrorResponse() (i.e., it lacks a string `error` field) but was routed to the error-throwing path. The raw data is JSON-stringified into the message. This typically indicates a non-W3C-compliant or malformed response from the remote end.
Source
Thrown at javascript/selenium-webdriver/lib/error.js:532
* if the provided `data` is not a valid encoded error.
*
* @param {{error: string, message: string}} data The error data to decode.
* @throws {WebDriverError} the decoded error.
* @see https://w3c.github.io/webdriver/webdriver-spec.html#protocol
*/
function throwDecodedError(data) {
if (isErrorResponse(data)) {
let ctor = ERROR_CODE_TO_TYPE.get(data.error) || WebDriverError
let err = new ctor(data.message)
// TODO(jleyba): remove whichever case is excluded from the final W3C spec.
if (typeof data.stacktrace === 'string') {
err.remoteStacktrace = data.stacktrace
} else if (typeof data.stackTrace === 'string') {
err.remoteStacktrace = data.stackTrace
}
throw err
}
throw new WebDriverError('Unknown error: ' + JSON.stringify(data))
}
/**
* Checks a legacy response from the Selenium 2.0 wire protocol for an error.
* @param {*} responseObj the response object to check.
* @return {*} responseObj the original response if it does not define an error.
* @throws {WebDriverError} if the response object defines an error.
*/
function checkLegacyResponse(responseObj) {
// Handle the legacy Selenium error response format.
if (isObject(responseObj) && typeof responseObj.status === 'number' && responseObj.status !== 0) {
const { status, value } = responseObj
let ctor = LEGACY_ERROR_CODE_TO_TYPE.get(status) || WebDriverError
if (!value || typeof value !== 'object') {
throw new ctor(value + '')
} else {View on GitHub (pinned to aa36b38e69)
Solutions
- Inspect the JSON-stringified data in the error message to see what the server actually returned.
- Verify the remote endpoint URL is correct and points to a WebDriver-compatible server.
- Check for intermediate proxies (nginx, corporate proxy) that may inject non-protocol responses.
- Upgrade the remote server/Grid to a W3C-compliant version matching the client.
- Enable debug logging to capture the raw HTTP response.
Defensive patterns
Strategy: try-catch
Try / catch
try {
// ... execute WebDriver command ...
} catch (e) {
if (e instanceof WebDriverError && e.message.startsWith('Unknown error:')) {
console.error('Non-W3C response from server. Raw data:', e.message)
// check server URL, proxy, server version
}
throw e
} Prevention
- Ensure the remote server/Grid is W3C-compliant and version-compatible with the client.
- Verify the endpoint URL and check for intermediate proxies returning non-protocol JSON.
- Enable Selenium debug logging to inspect raw HTTP responses during troubleshooting.
- Validate the server is reachable and responding with WebDriver protocol responses.
When it happens
Trigger: The remote WebDriver/Grid endpoint returns a response object without an `error` string field where one was expected. A proxy or middleware returns unexpected JSON. A server returns an HTML error page that was parsed into a non-error object. Version mismatch between client expectations and server response shape.
Common situations: Misbehaving or outdated Selenium Grid/server; intermediate reverse proxy returning its own error JSON; third-party cloud grid with a non-standard error envelope; server crash returning a non-protocol response.
Related errors
- ${message}
- {error}: {response['message']}
- no sessionId in returned payload
- Switch to desired window before changing its size
- Switch to desired window before getting its size
AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14).
Data as JSON: /api/errors/c97f08ae4dd44e6a.
Report an issue: GitHub.