SeleniumHQ/selenium · error · Error
Http method must be a string. Received: '${method})'
Error message
Http method must be a string. Received: '${method})' What it means
Thrown by `ContinueRequestParameters.method()` when the argument is not a string (`typeof method !== 'string'`). The method stores the value directly into the BiDi command map. The error string carries a cosmetic typo: an extra `)` (`'${method})'`).
Source
Thrown at javascript/selenium-webdriver/bidi/continueRequestParameters.js:95
throw new Error(`Header value must be an instance of Header. Received:'${header}'`)
}
headerList.push(Object.fromEntries(header.asMap()))
})
this.#map.set('headers', headerList)
return this
}
/**
* Sets the HTTP method for the request.
*
* @param {string} method - The HTTP method to be set.
* @returns {ContinueRequestParameters} - The updated `continueRequestParameters` object.
* @throws {Error} - If the method parameter is not a string.
*/
method(method) {
if (typeof method !== 'string') {
throw new Error(`Http method must be a string. Received: '${method})'`)
}
this.#map.set('method', method)
return this
}
/**
* Sets the URL for the request.
*
* @param {string} url - The URL to set for the request.
* @returns {ContinueRequestParameters} - The current instance of the ContinueRequestParameters for chaining.
* @throws {Error} - If the url parameter is not a string.
*/
url(url) {
if (typeof url !== 'string') {
throw new Error(`Url must be a string. Received:'${url}'`)
}
this.#map.set('url', url)View on GitHub (pinned to aa36b38e69)
Solutions
- Pass a plain string such as 'GET', 'POST', 'PUT', 'DELETE'
- Ensure the variable is defined and is a string before calling
Example fix
// before
params.method(req.methodNumber)
// after
params.method('POST') Defensive patterns
Strategy: validation
Validate before calling
if (typeof method === 'string') params.method(method)
Type guard
const isHttpMethod = (m) => typeof m === 'string'
Prevention
- Use string literals for HTTP methods, not numeric codes
- Check typeof before calling when the source is dynamic
When it happens
Trigger: Calling `params.method(undefined)`, `params.method(200)`, or passing a numeric/enum object instead of a string verb.
Common situations: Passing a method from a typed enum that resolves to a non-string; forgetting to set the method so it is undefined; confusing an HTTP status number with the method.
Related errors
- Reason phrase must be a string. Received: '${reasonPhrase})'
- Value must be an instance of BytesValue. Received: '${value}
- Url must be a string. Received:'${url}'
- Username must be a string. Received:'${username}'
- Password must be a string. Received:'${password}'
AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14).
Data as JSON: /api/errors/aaa2eacb0ed30838.
Report an issue: GitHub.