SeleniumHQ/selenium · error · Error
Unrecognized command: ${command.getName()}
Error message
Unrecognized command: ${command.getName()} What it means
Thrown as a generic Error by webdriver.http.Executor.execute() when a Command's name does not match any entry in the executor's customCommands_ map or the static COMMAND_MAP_. The executor looks up the command name to obtain its HTTP method and path template; if neither source has it, the command is unrecognized and cannot be sent over the wire. This is from the legacy javascript/webdriver (Closure-based) HTTP layer.
Source
Thrown at javascript/webdriver/http/http.js:110
* @param {string} name The command name.
* @param {string} method The HTTP method to use when sending this command.
* @param {string} path The path to send the command to, relative to
* the WebDriver server's command root and of the form
* "/path/:variable/segment".
*/
webdriver.http.Executor.prototype.defineCommand = function(
name, method, path) {
this.customCommands_[name] = {method: method, path: path};
};
/** @override */
webdriver.http.Executor.prototype.execute = function(command) {
var resource =
this.customCommands_[command.getName()] ||
webdriver.http.Executor.COMMAND_MAP_[command.getName()];
if (!resource) {
throw new Error('Unrecognized command: ' + command.getName());
}
var parameters = command.getParameters();
var path = webdriver.http.Executor.buildPath_(resource.path, parameters);
var request = new webdriver.http.Request(resource.method, path, parameters);
var log = this.log_;
log.finer(function() {
return '>>>\n' + request;
});
return this.client_.send(request).then(function(response) {
log.finer(function() {
return '<<<\n' + response;
});
return webdriver.http.Executor.parseHttpResponse_(
/** @type {!webdriver.http.Response} */ (response));
});View on GitHub (pinned to aa36b38e69)
Solutions
- Check that the command name string exactly matches a name registered in webdriver.http.Executor.COMMAND_MAP_ or previously added via defineCommand().
- If using a custom endpoint, register it first: executor.defineCommand('myCommand', 'POST', '/session/:sessionId/my-command').
- Verify the command name constant exists in the version of the library you are using — consult the command.Name enumeration.
Example fix
// before
executor.execute(new webdriver.command.Command('NonexistentCommand'))
// after
executor.defineCommand(
'MyCustomCommand', 'POST', '/session/:sessionId/custom'
)
executor.execute(
new webdriver.command.Command('MyCustomCommand')
) Defensive patterns
Strategy: validation
Validate before calling
const known = Object.assign(
{}, executor.customCommands_,
webdriver.http.Executor.COMMAND_MAP_
)
if (command.getName() in known) {
executor.execute(command)
} Try / catch
try {
executor.execute(command)
} catch (e) {
if (/Unrecognized command/.test(e.message)) {
// register the command or fix the name
} else throw e
} Prevention
- Register custom commands with defineCommand() before executing them.
- Use the built-in command.Name constants rather than string literals.
- Verify command names against COMMAND_MAP_ for the library version in use.
When it happens
Trigger: Calling executor.execute(command) where command.getName() returns a string that was never registered via defineCommand() and is not part of the built-in COMMAND_MAP_. This happens when constructing a Command with a misspelled or non-existent command name.
Common situations: Using a command name that does not exist in the W3C/legacy WebDriver command set; referencing a custom command that was never registered via defineCommand(); a typo in the command name constant; version mismatch where a command was renamed or removed.
Related errors
- Missing required parameter: ${key}
- events should be string or string array
- browsingContexts should be string or string array
- Params must be an instance of AddInterceptParameters. Receiv
- Params must be an instance of ContinueRequestParameters. Rec
AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14).
Data as JSON: /api/errors/9e348cfd72d344db.
Report an issue: GitHub.