SeleniumHQ/selenium · error · Error

Password must be a string. Received:'${password}'

Error message

Password must be a string. Received:'${password}'

What it means

Thrown by `ContinueResponseParameters.credentials()` when the second argument (password) is not a string. Because username is validated first, a bad username throws [27] before this one can fire; this error means the username was valid but the password was not a string.

Source

Thrown at javascript/selenium-webdriver/bidi/continueResponseParameters.js:65

    this.#map.set('cookies', cookies)
    return this
  }

  /**
   * Sets the credentials for authentication.
   *
   * @param {string} username - The username for authentication.
   * @param {string} password - The password for authentication.
   * @returns {ContinueResponseParameters} The current instance of the ContinueResponseParameters for chaining.
   * @throws {Error} If username or password is not a string.
   */
  credentials(username, password) {
    if (typeof username !== 'string') {
      throw new Error(`Username must be a string. Received:'${username}'`)
    }

    if (typeof password !== 'string') {
      throw new Error(`Password must be a string. Received:'${password}'`)
    }

    this.#map.set('credentials', { type: 'password', username: username, password: password })

    return this
  }

  /**
   * Sets the headers for the response.
   *
   * @param {Header[]} headers - An array of Header objects representing the headers.
   * @returns {ContinueResponseParameters} - The current instance of the ContinueResponseParameters for chaining.
   * @throws {Error} - If the header value is not an instance of Header.
   */
  headers(headers) {
    const headerList = []
    headers.forEach((header) => {
      if (!(header instanceof Header)) {

View on GitHub (pinned to aa36b38e69)

Solutions

  1. Pass a string password: `params.credentials('user', 'pass')`
  2. Resolve the secret to a string before calling

Example fix

// before
params.credentials('user', secretFromManager)
// after
params.credentials('user', String(secretFromManager))
Defensive patterns

Strategy: validation

Validate before calling

if (typeof password === 'string') params.credentials(username, password)

Type guard

const isPasswordString = (p) => typeof p === 'string'

Prevention

When it happens

Trigger: Calling `params.credentials('user', undefined)` or `params.credentials('user', 123)`.

Common situations: Password from an env var that is unset; passing a secret-manager object/result instead of the resolved string value.

Related errors


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