{"record":{"id":"0134d50672a91166","repo":"reflex-dev/reflex","slug":"frontend-functionality-requires-selenium-to-be-i","errorCode":null,"errorMessage":"Frontend functionality requires `selenium` to be installed, and it could not be imported.","messagePattern":"Frontend functionality requires `selenium` to be installed, and it could not be imported\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"reflex/testing.py","lineNumber":641,"sourceCode":"            driver_clz: webdriver.Chrome (default), webdriver.Firefox, webdriver.Safari,\n                webdriver.Edge, etc\n            driver_kwargs: additional keyword arguments to pass to the webdriver constructor\n            driver_options: selenium ArgOptions instance to pass to the webdriver constructor\n            driver_option_args: additional arguments for the webdriver options\n            driver_option_capabilities: additional capabilities for the webdriver options\n\n        Returns:\n            Instance of the given webdriver navigated to the frontend url of the app.\n\n        Raises:\n            RuntimeError: when selenium is not importable or frontend is not running\n        \"\"\"\n        if not has_selenium:\n            msg = (\n                \"Frontend functionality requires `selenium` to be installed, \"\n                \"and it could not be imported.\"\n            )\n            raise RuntimeError(msg)\n        if self.frontend_url is None:\n            msg = \"Frontend is not running.\"\n            raise RuntimeError(msg)\n        want_headless = False\n        if environment.APP_HARNESS_HEADLESS.get():\n            want_headless = True\n        if driver_clz is None:\n            requested_driver = environment.APP_HARNESS_DRIVER.get()\n            driver_clz = getattr(webdriver, requested_driver)  # pyright: ignore [reportPossiblyUnboundVariable]\n            if driver_options is None:\n                driver_options = getattr(webdriver, f\"{requested_driver}Options\")()  # pyright: ignore [reportPossiblyUnboundVariable]\n        if driver_clz is webdriver.Chrome:  # pyright: ignore [reportPossiblyUnboundVariable]\n            if driver_options is None:\n                from selenium.webdriver.chrome.options import Options\n\n                driver_options = Options()  # pyright: ignore [reportPossiblyUnboundVariable]\n            driver_options.add_argument(\"--class=AppHarness\")\n            if want_headless:","sourceCodeStart":623,"sourceCodeEnd":659,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/reflex/testing.py#L623-L659","documentation":"RuntimeError from AppHarness.frontend when the selenium package cannot be imported. The Selenium-based driver helpers are optional in Reflex's testing layer, so calling frontend() without selenium installed fails fast with this message.","triggerScenarios":"Calling harness.frontend() (or the driver fixture) in an environment where `import selenium` failed at module import time (has_selenium is False). Triggered by tests like test_connection_banner, test_component_state_app, etc.","commonSituations":"Running the integration suite without the selenium extra installed; new venv/CI image missing selenium; using Playwright-based tests but accidentally calling the selenium API.","solutions":["Install selenium: `uv add selenium` or `pip install selenium` (plus a webdriver such as chromedriver / selenium-manager bundled)","Prefer the Playwright-based tests in tests/integration/tests_playwright for new tests","Skip selenium-dependent tests when the package is absent (e.g. pytest.importorskip(\"selenium\"))"],"exampleFix":"# before\nharness.frontend()  # RuntimeError: selenium not installed\n\n# after\npytest.importorskip(\"selenium\")\nharness.frontend()","handlingStrategy":"validation","validationCode":"try:\n    import selenium  # noqa: F401\n    has_selenium = True\nexcept ImportError:\n    has_selenium = False\n\nif not has_selenium:\n    pytest.skip(\"selenium not installed\")","typeGuard":"def selenium_available() -> bool:\n    try:\n        import selenium\n        return True\n    except ImportError:\n        return False","tryCatchPattern":"try:\n    driver = harness.frontend()\nexcept RuntimeError as e:\n    if \"selenium\" in str(e):\n        pytest.skip(str(e))\n    raise","preventionTips":["Install the testing extras (selenium + a browser driver) before running integration tests","Prefer Playwright tests (tests/integration/tests_playwright) for new coverage"],"tags":["reflex","testing","selenium","optional-dependency"],"backgroundTag":"missing-optional-dependency","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}