SeleniumHQ/selenium · warning · TypeError
no capabilities provided for merge
Error message
no capabilities provided for merge
What it means
Thrown by Capabilities.merge() when the argument is falsy (null, undefined, 0, '', false). The method requires a non-null Capabilities, Map, or plain object to merge from. A falsy argument means nothing was provided to merge.
Source
Thrown at javascript/selenium-webdriver/lib/capabilities.js:344
* set of capabilities to merge.
* @return {!Capabilities} A self reference.
*/
merge(other) {
if (other) {
let otherMap
if (other instanceof Capabilities) {
otherMap = other.map_
} else if (other instanceof Map) {
otherMap = other
} else {
otherMap = toMap(other)
}
otherMap.forEach((value, key) => {
this.set(key, value)
})
return this
} else {
throw new TypeError('no capabilities provided for merge')
}
}
/**
* Deletes an entry from this set of capabilities.
*
* @param {string} key the capability key to delete.
*/
delete(key) {
this.map_.delete(key)
}
/**
* @param {string} key The capability key.
* @param {*} value The capability value.
* @return {!Capabilities} A self reference.
* @throws {TypeError} If the `key` is not a string.
*/View on GitHub (pinned to aa36b38e69)
Solutions
- Guard the merge call: if (other) caps.merge(other).
- Default to an empty object: caps.merge(other || {}).
- Initialize the variable to a Capabilities or empty object before merging.
- Skip merging entirely if no additional capabilities are needed.
Example fix
// before caps.merge(maybeCaps) // maybeCaps is null // after if (maybeCaps) caps.merge(maybeCaps)
Defensive patterns
Strategy: validation
Validate before calling
if (!other) {
// nothing to merge; skip or throw a clearer error
return caps
}
caps.merge(other) Prevention
- Guard merge calls with a truthiness check: if (other) caps.merge(other).
- Initialize optional capability objects to an empty Capabilities or {} rather than null.
- Use default parameters: function setup(caps, extra = {}) { caps.merge(extra) }.
When it happens
Trigger: Calling capabilities.merge(null), merge(undefined), or merging a variable that was conditionally assigned and not set. Chaining merges where an optional config object is absent.
Common situations: Optional capability sources not initialized; conditional merging where the source may be null; merging values from a lookup that returned nothing; default parameter not provided.
Related errors
- Capability keys must be strings: ${typeof key}
- Invalid URL: ${aUrl}
- Level must be >= 0
- Strategy can only be one of the following: normal, eager, no
- Behavior can only be one of the following: dismiss, accept,
AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14).
Data as JSON: /api/errors/33b80c4b8238727c.
Report an issue: GitHub.