SeleniumHQ/selenium · error · Error

Url must be a string. Received:'${url}'

Error message

Url must be a string. Received:'${url}'

What it means

Thrown by `ContinueRequestParameters.url()` when the argument is not a string (`typeof url !== 'string'`). The value is stored directly into the BiDi command map without coercion, so a `URL` object or `undefined` is rejected.

Source

Thrown at javascript/selenium-webdriver/bidi/continueRequestParameters.js:110

   */
  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)
    return this
  }

  asMap() {
    return this.#map
  }
}

module.exports = { ContinueRequestParameters }

View on GitHub (pinned to aa36b38e69)

Solutions

  1. Pass a plain string, calling `.href` or `.toString()` on any URL object first
  2. Ensure the variable is a defined string

Example fix

// before
params.url(new URL('https://example.com'))
// after
params.url('https://example.com')
Defensive patterns

Strategy: validation

Validate before calling

if (typeof url === 'string') params.url(url)

Type guard

const isUrlString = (u) => typeof u === 'string'

Prevention

When it happens

Trigger: Calling `params.url(new URL('https://...'))` (a URL object is not a string type), `params.url(null)`, or passing a parsed URL object from another library.

Common situations: Passing a `URL` object instead of `.href`/`.toString()`; undefined URL from optional config; reusing a WHATWG URL instance.

Related errors


AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14). Data as JSON: /api/errors/e999e5b59d298e64. Report an issue: GitHub.