{"record":{"id":"7805b36fe36f6d00","repo":"SeleniumHQ/selenium","slug":"unsuccessful-command-executed-command-code","errorCode":null,"errorMessage":"Unsuccessful command executed: #{command} - Code #{code}\\n#{result}\\n#{stderr}","messagePattern":"Unsuccessful command executed: #(.+?) - Code #(.+?)\\\\n#(.+?)\\\\n#(.+?)","errorType":"exception","errorClass":"Error::WebDriverError","httpStatus":null,"severity":"critical","filePath":"rb/lib/selenium/webdriver/common/selenium_manager.rb","lineNumber":118,"sourceCode":"\n          json_output['logs'].each do |log|\n            level = log['level'].casecmp('info').zero? ? 'debug' : log['level'].downcase\n            WebDriver.logger.send(level, log['message'], id: :selenium_manager)\n          end\n\n          json_output['result']\n        end\n\n        def validate_command_result(command, status, result, stderr)\n          if status.nil? || status.exitstatus.nil?\n            WebDriver.logger.info(\"No exit status for: #{command}. Assuming success if result is present.\",\n                                  id: :selenium_manager)\n          end\n\n          return unless status&.exitstatus&.positive? || result.nil?\n\n          code = status&.exitstatus || 'exit status not available'\n          raise Error::WebDriverError,\n                \"Unsuccessful command executed: #{command} - Code #{code}\\n#{result}\\n#{stderr}\"\n        end\n      end\n    end # SeleniumManager\n  end # WebDriver\nend # Selenium\n","sourceCodeStart":100,"sourceCodeEnd":125,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/rb/lib/selenium/webdriver/common/selenium_manager.rb#L100-L125","documentation":"Raised by SeleniumManager.validate_command_result when the selenium-manager binary exits with a positive (non-zero) exit code, or when the result is nil (no valid JSON output). The message includes the exit code, stdout (parsed result), and stderr from the binary, providing diagnostic detail about why driver resolution failed.","triggerScenarios":"The binary runs but cannot find a suitable browser or driver (e.g., Chrome is not installed). The binary cannot download a driver due to network restrictions. Browser and driver version mismatch. The binary outputs invalid JSON or an error message in the result field. Firewall/proxy blocking the driver download endpoint.","commonSituations":"Running in CI without a browser pre-installed and no network access for auto-download. Corporate proxy blocking driver downloads. Browser updated but the cached driver is incompatible. Running on an architecture where no matching driver exists (e.g., ARM Linux with Chrome for x86).","solutions":["Read the stderr/result in the error message: it typically states the exact reason (browser not found, download failed, version mismatch).","Pre-install the correct driver and specify its path via Service.driver_path= to bypass Selenium Manager.","Ensure the browser is installed and discoverable (check PATH, check the expected install location).","If behind a proxy, set HTTP_PROXY/HTTPS_PROXY environment variables so selenium-manager can download drivers.","Upgrade the selenium-webdriver gem to get a newer selenium-manager binary with broader compatibility."],"exampleFix":"// before\n# selenium-manager fails: cannot find matching chromedriver\noptions = Selenium::WebDriver::Options.chrome\ndriver = Selenium::WebDriver.for :chrome, options: options\n\n// after (specify driver explicitly)\nservice = Selenium::WebDriver::Service.chrome(driver_path: '/usr/local/bin/chromedriver-120')\noptions = Selenium::WebDriver::Options.chrome\ndriver = Selenium::WebDriver.for :chrome, service: service, options: options","handlingStrategy":"try-catch","validationCode":"# Pre-validate browser presence before launching driver\ndef browser_installed?(browser)\n  case browser\n  when :chrome\n    system('which google-chrome google-chrome-stable chromium chromium-browser 2>/dev/null', out: '/dev/null')\n  when :firefox\n    system('which firefox 2>/dev/null', out: '/dev/null')\n  else\n    false\n  end\nend","typeGuard":null,"tryCatchPattern":"begin\n  driver = Selenium::WebDriver.for :chrome\nrescue Selenium::WebDriver::Error::WebDriverError => e\n  raise unless e.message.include?('Unsuccessful command executed')\n  # parse the stderr in the message for diagnostics\n  warn \"Selenium Manager failed: #{e.message}\"\n  service = Selenium::WebDriver::Service.chrome(driver_path: ENV.fetch('CHROMEDRIVER_PATH'))\n  driver = Selenium::WebDriver.for(:chrome, service: service)\nend","preventionTips":["Pre-install browser and matching driver in CI/Docker images rather than relying on auto-download.","Set HTTP_PROXY/HTTPS_PROXY in environments behind corporate firewalls.","Pin browser and driver versions explicitly using Service.driver_path=.","Log the full error message (it contains selenium-manager's stderr) for diagnosis."],"tags":["selenium-manager","driver-resolution","network","browser","ruby"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}