{"record":{"id":"b1a9832bf6a6a071","repo":"SeleniumHQ/selenium","slug":"unsuccessful-command-executed-command-code-c","errorCode":null,"errorMessage":"Unsuccessful command executed: {command}; code: {completed_proc.returncode}\\n{result}\\n{stderr}","messagePattern":"Unsuccessful command executed: (.+?); code: (.+?)\\\\n(.+?)\\\\n(.+?)","errorType":"exception","errorClass":"WebDriverException","httpStatus":null,"severity":"error","filePath":"py/selenium/webdriver/common/selenium_manager.py","lineNumber":154,"sourceCode":"            The log string containing the driver location.\n        \"\"\"\n        command = \" \".join(args)\n        logger.debug(\"Executing process: %s\", command)\n        try:\n            if sys.platform == \"win32\":\n                completed_proc = subprocess.run(args, capture_output=True, creationflags=subprocess.CREATE_NO_WINDOW)\n            else:\n                completed_proc = subprocess.run(args, capture_output=True)\n            stdout = completed_proc.stdout.decode(\"utf-8\").rstrip(\"\\n\")\n            stderr = completed_proc.stderr.decode(\"utf-8\").rstrip(\"\\n\")\n            output = json.loads(stdout) if stdout != \"\" else {\"logs\": [], \"result\": {}}\n        except Exception as err:\n            raise WebDriverException(f\"Unsuccessful command executed: {command}\") from err\n\n        SeleniumManager._process_logs(output[\"logs\"])\n        result = output[\"result\"]\n        if completed_proc.returncode:\n            raise WebDriverException(\n                f\"Unsuccessful command executed: {command}; code: {completed_proc.returncode}\\n{result}\\n{stderr}\"\n            )\n        return result\n\n    @staticmethod\n    def _process_logs(log_items: list[dict]):\n        for item in log_items:\n            if item[\"level\"] == \"WARN\":\n                logger.warning(item[\"message\"])\n            elif item[\"level\"] in [\"DEBUG\", \"INFO\"]:\n                logger.debug(item[\"message\"])\n","sourceCodeStart":136,"sourceCodeEnd":166,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/py/selenium/webdriver/common/selenium_manager.py#L136-L166","documentation":"Raised by SeleniumManager._run() after the process completed but returned a non-zero exit code. The message includes the command, the numeric code, the parsed 'result' dict, and stderr — all of which come from the selenium-manager binary itself. This is the primary error surface for driver auto-management failures: the manager ran successfully as a process but could not fulfill the request.","triggerScenarios":"Selenium Manager could not find a browser installed on the system, could not download the matching driver (network/proxy/firewall block), detected a version mismatch between browser and driver, or the cache directory is unwritable. The embedded 'result' and stderr fields describe the exact reason.","commonSituations":"Headless CI with no browser installed, corporate egress proxy blocking github.com/googlechromelabs downloads, a browser auto-updated past the cached driver, a broken or pinned incompatible driver version, and read-only HOME/cache directories.","solutions":["Read the 'result' and stderr portions of the message — they name the specific failure (browser not found, driver download error, etc.).","If a driver download is blocked, pre-place the driver and pass executable_path to the Service, or set the relevant env var (e.g. SE_CHROMEDRIVER, SE_GECKODRIVER).","Ensure the target browser is actually installed and discoverable; on Linux check that the browser is on PATH or in a standard location.","Set SE_MANAGER_PATH to a known-good manager or clear the Selenium Manager cache (~/.cache/selenium/) if it is corrupt."],"exampleFix":"# before — no browser, manager fails to download driver\n#   ...code: 2 ... {browser not found} ...\n\n# after — pin a local driver via Service\nfrom selenium.webdriver.chrome.service import Service\nservice = Service(executable_path='/opt/chromedriver/chromedriver')\ndriver = webdriver.Chrome(service=service)","handlingStrategy":"fallback","validationCode":"null","typeGuard":"null","tryCatchPattern":"from selenium.common.exceptions import WebDriverException\ntry:\n    driver = webdriver.Chrome()\nexcept WebDriverException as e:\n    if 'Unsuccessful command executed' in str(e) and 'code:' in str(e):\n        # fall back to a pre-placed driver\n        from selenium.webdriver.chrome.service import Service\n        driver = webdriver.Chrome(service=Service(executable_path='/opt/chromedriver'))","preventionTips":["Pre-stage driver binaries in CI images so a manager download failure is non-fatal.","Read the embedded 'result'/'stderr' text to classify the failure before retrying.","Allowlist driver-download hosts in corporate proxies."],"tags":["selenium-manager","driver-download","network","version-mismatch","diagnostics"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}