{"record":{"id":"9e348cfd72d344db","repo":"SeleniumHQ/selenium","slug":"unrecognized-command-command-getname","errorCode":null,"errorMessage":"Unrecognized command: ${command.getName()}","messagePattern":"Unrecognized command: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"javascript/webdriver/http/http.js","lineNumber":110,"sourceCode":" * @param {string} name The command name.\n * @param {string} method The HTTP method to use when sending this command.\n * @param {string} path The path to send the command to, relative to\n *     the WebDriver server's command root and of the form\n *     \"/path/:variable/segment\".\n */\nwebdriver.http.Executor.prototype.defineCommand = function(\n    name, method, path) {\n  this.customCommands_[name] = {method: method, path: path};\n};\n\n\n/** @override */\nwebdriver.http.Executor.prototype.execute = function(command) {\n  var resource =\n      this.customCommands_[command.getName()] ||\n      webdriver.http.Executor.COMMAND_MAP_[command.getName()];\n  if (!resource) {\n    throw new Error('Unrecognized command: ' + command.getName());\n  }\n\n  var parameters = command.getParameters();\n  var path = webdriver.http.Executor.buildPath_(resource.path, parameters);\n  var request = new webdriver.http.Request(resource.method, path, parameters);\n\n  var log = this.log_;\n  log.finer(function() {\n    return '>>>\\n' + request;\n  });\n\n  return this.client_.send(request).then(function(response) {\n    log.finer(function() {\n      return '<<<\\n' + response;\n    });\n    return webdriver.http.Executor.parseHttpResponse_(\n          /** @type {!webdriver.http.Response} */ (response));\n  });","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/javascript/webdriver/http/http.js#L92-L128","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nexecutor.execute(new webdriver.command.Command('NonexistentCommand'))\n\n// after\nexecutor.defineCommand(\n  'MyCustomCommand', 'POST', '/session/:sessionId/custom'\n)\nexecutor.execute(\n  new webdriver.command.Command('MyCustomCommand')\n)","handlingStrategy":"validation","validationCode":"const known = Object.assign(\n  {}, executor.customCommands_,\n  webdriver.http.Executor.COMMAND_MAP_\n)\nif (command.getName() in known) {\n  executor.execute(command)\n}","typeGuard":null,"tryCatchPattern":"try {\n  executor.execute(command)\n} catch (e) {\n  if (/Unrecognized command/.test(e.message)) {\n    // register the command or fix the name\n  } else throw e\n}","preventionTips":["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."],"tags":["javascript","http","executor","command","legacy-webdriver"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}