SeleniumHQ/selenium · error · Error
Value must be an instance of BytesValue. Received:'${value}'
Error message
Value must be an instance of BytesValue. Received:'${value}' What it means
Thrown by `CookieFilter.value()` when the argument is not a `BytesValue` instance. The method calls `value.asMap()` to serialize the cookie value into the getCookies filter, so it requires a real `BytesValue` carrying a type and value — a raw string is rejected.
Source
Thrown at javascript/selenium-webdriver/bidi/cookieFilter.js:47
*
* @param {string} name - The name of the cookie.
* @returns {CookieFilter} - The updated CookieFilter instance for chaining.
*/
name(name) {
this.#map.set('name', name)
return this
}
/**
* Sets the value of the cookie.
*
* @param {BytesValue} value - The value to be set. Must be an instance of BytesValue.
* @returns {CookieFilter} - The updated CookieFilter instance for chaining.
* @throws {Error} - If the value is not an instance of BytesValue.
*/
value(value) {
if (!(value instanceof BytesValue)) {
throw new Error(`Value must be an instance of BytesValue. Received:'${value}'`)
}
this.#map.set('value', Object.fromEntries(value.asMap()))
return this
}
/**
* Sets the domain for the cookie.
*
* @param {string} domain - The domain to set.
* @returns {CookieFilter} - The updated CookieFilter instance for chaining.
*/
domain(domain) {
this.#map.set('domain', domain)
return this
}
/**
* Sets the url path for the cookie to be fetched.View on GitHub (pinned to aa36b38e69)
Solutions
- Wrap the value in `new BytesValue(BytesValue.Type.STRING, value)`
- Import `{ BytesValue }` from `selenium-webdriver/bidi/networkTypes`
- value() is optional in CookieFilter — omit it if you do not have a BytesValue
Example fix
// before
filter.value('sessionid')
// after
const { BytesValue } = require('selenium-webdriver/bidi/networkTypes')
filter.value(new BytesValue(BytesValue.Type.STRING, 'sessionid')) Defensive patterns
Strategy: type-guard
Validate before calling
const { BytesValue } = require('selenium-webdriver/bidi/networkTypes')
if (value instanceof BytesValue) filter.value(value) Type guard
const { BytesValue } = require('selenium-webdriver/bidi/networkTypes')
const isBytesValue = (v) => v instanceof BytesValue Prevention
- Cookie values in filters must be BytesValue, not raw strings
- value() is optional in CookieFilter — omit it if you don't have a BytesValue
When it happens
Trigger: Calling `filter.value('sessionid')` with a raw string; passing `{type:'string', value:'x'}`; reusing a Cookie's value getter without confirming it is a BytesValue.
Common situations: Developers assume a plain string cookie value works; building a filter from deserialized cookie data.
Related errors
- Value must be an instance of BytesValue. Received: '${value}
- CookieHeader must be an instance of Header. Received:'${head
- CookieHeader must be an instance of Header. Received:'${head
- ClipRectangle must be an instance of ClipRectangle. Received
- Header value must be an instance of Header. Received:'${head
AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14).
Data as JSON: /api/errors/f51bfd8112bee13d.
Report an issue: GitHub.