SeleniumHQ/selenium · error · Error
Params must be an instance of AddInterceptParameters. Receiv
Error message
Params must be an instance of AddInterceptParameters. Received:'${params}' What it means
Thrown by Network.addIntercept() when the params argument is not an instance of the AddInterceptParameters class. The method serializes the params via params.asMap() to build the network.addIntercept BiDi command, so it requires the exact class to guarantee the payload shape. A plain object, string, or any other type is rejected because it lacks the asMap() contract.
Source
Thrown at javascript/selenium-webdriver/bidi/network.js:203
params.errorText,
)
}
this.invokeCallbacks(eventType, response)
}
})
return id
}
/**
* Adds a network intercept.
*
* @param {AddInterceptParameters} params - The parameters for the network intercept.
* @returns {Promise<string>} - A promise that resolves to the added intercept's id.
* @throws {Error} - If params is not an instance of AddInterceptParameters.
*/
async addIntercept(params) {
if (!(params instanceof AddInterceptParameters)) {
throw new Error(`Params must be an instance of AddInterceptParameters. Received:'${params}'`)
}
const command = {
method: 'network.addIntercept',
params: Object.fromEntries(params.asMap()),
}
let response = await this.bidi.send(command)
return response.result.intercept
}
/**
* Removes an intercept.
*
* @param {string} interceptId - The ID of the intercept to be removed.
* @returns {Promise<void>} - A promise that resolves when the intercept is successfully removed.
*/View on GitHub (pinned to aa36b38e69)
Solutions
- Construct and pass an AddInterceptParameters instance: import { AddInterceptParameters } and call new AddInterceptParameters().phases([...]).intercepts([...]) before network.addIntercept(params).
- Confirm the import path matches the class instance type at runtime (instanceof relies on the same class reference, not a structurally identical copy).
- If you have a plain object, translate it into an AddInterceptParameters instance rather than passing it directly.
Example fix
// before
await network.addIntercept({ phases: ['beforeRequestSent'], urlPatterns: [...] })
// after
const { AddInterceptParameters } = require('selenium-webdriver/bidi/addInterceptParameters')
const params = new AddInterceptParameters()
.phases([Network.Phase.BEFORE_REQUEST_SENT])
.urlPatterns([...])
await network.addIntercept(params) Defensive patterns
Strategy: type-guard
Validate before calling
if (!(params instanceof AddInterceptParameters)) {
throw new TypeError('addIntercept requires AddInterceptParameters')
} Type guard
function isAddInterceptParameters(v) {
return v instanceof AddInterceptParameters
} Try / catch
try {
await network.addIntercept(params)
} catch (e) {
if (/instance of AddInterceptParameters/.test(e.message)) {
// rebuild params as AddInterceptParameters
} else throw e
} Prevention
- Always construct AddInterceptParameters via its builder; never pass plain objects.
- Keep a single import for AddInterceptParameters to avoid duplicate class references that break instanceof.
- Use TypeScript/JSDoc types so the editor flags plain-object arguments.
When it happens
Trigger: Calling network.addIntercept({...}) with a literal object, calling addIntercept('phase:beforeRequestSent'), calling addIntercept(undefined), or passing a ContinueRequestParameters/ProvideResponseParameters object by mistake.
Common situations: Copying example code that built a raw object before the Parameters API existed; passing the wrong parameter class when chaining several network calls; forgetting to import AddInterceptParameters and substituting a plain object.
Related errors
- Params must be an instance of ContinueRequestParameters. Rec
- Params must be an instance of ContinueResponseParameters. Re
- Params must be an instance of ProvideResponseParameters. Rec
- Pattern must be an instance of UrlPattern. Received: '${patt
- Pattern must be an instance of UrlPattern. Received:'${patte
AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14).
Data as JSON: /api/errors/695d9ed5e5a13da0.
Report an issue: GitHub.