{"record":{"id":"c50eebad4709c07e","repo":"SeleniumHQ/selenium","slug":"module-selenium-webdriver-has-no-attribute-name","errorCode":null,"errorMessage":"module 'selenium.webdriver' has no attribute {name!r}","messagePattern":"module 'selenium\\.webdriver' has no attribute (.+?)","errorType":"exception","errorClass":"AttributeError","httpStatus":null,"severity":"error","filePath":"py/selenium/webdriver/__init__.py","lineNumber":103,"sourceCode":"    \"safari\": \"selenium.webdriver.safari\",\n    \"support\": \"selenium.webdriver.support\",\n    \"webkitgtk\": \"selenium.webdriver.webkitgtk\",\n    \"wpewebkit\": \"selenium.webdriver.wpewebkit\",\n}\n\n\ndef __getattr__(name):\n    if name in _LAZY_IMPORTS:\n        module_path, attr_name = _LAZY_IMPORTS[name]\n        module = importlib.import_module(module_path)\n        value = getattr(module, attr_name)\n        globals()[name] = value\n        return value\n    if name in _LAZY_SUBMODULES:\n        module = importlib.import_module(_LAZY_SUBMODULES[name])\n        globals()[name] = module\n        return module\n    raise AttributeError(f\"module 'selenium.webdriver' has no attribute {name!r}\")\n\n\ndef __dir__():\n    return sorted(set(__all__) | set(_LAZY_SUBMODULES.keys()))\n\n\n__all__ = sorted(_LAZY_IMPORTS.keys())\n","sourceCodeStart":85,"sourceCodeEnd":111,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/py/selenium/webdriver/__init__.py#L85-L111","documentation":"Raised as an AttributeError by selenium.webdriver.__getattr__() when a name accessed on the webdriver package is not in the _LAZY_IMPORTS mapping (top-level shortcuts like Chrome, Firefox, Keys) nor in _LAZY_SUBMODULES (subpackages like chrome, common, remote). The package uses PEP 562 lazy loading via __getattr__; any name outside both registries is not a valid attribute and the standard AttributeError is raised with a message naming the missing attribute.","triggerScenarios":"Accessing selenium.webdriver.SomeName where SomeName is not a registered lazy import (e.g. 'Chrome', 'Firefox', 'Keys', 'ActionChains') or a registered submodule (e.g. 'chrome', 'common', 'remote'). The __getattr__ function is invoked for any attribute not found normally.","commonSituations":"Misspelling a class name (e.g. webdriver.Chrom instead of webdriver.Chrome); accessing a class that exists but is not exported at the webdriver top level (e.g. webdriver.By should be selenium.webdriver.common.by.By); using a name from an older or newer Selenium version; IDE auto-import suggesting an invalid path.","solutions":["Check _LAZY_IMPORTS keys in selenium/webdriver/__init__.py for the exact valid top-level names (Chrome, Edge, Firefox, Ie, Safari, Remote, Keys, ActionChains, etc.).","For names not at the top level, import from their full path: e.g. `from selenium.webdriver.common.by import By`.","If the name is a submodule (chrome, common, remote), access it as selenium.webdriver.chrome etc.","Verify the Selenium version — the lazy import set may have changed between versions."],"exampleFix":"# before\nfrom selenium import webdriver\ndriver = webdriver.Chrom()  # typo, AttributeError\n\n# after\nfrom selenium import webdriver\ndriver = webdriver.Chrome()  # correct lazy import name\n# or for non-top-level names:\nfrom selenium.webdriver.common.by import By","handlingStrategy":"validation","validationCode":"import selenium.webdriver as wd\n_VALID = set(wd.__dir__())\nif name not in _VALID:\n    raise AttributeError(f'{name} not in webdriver. Valid: {sorted(_VALID)}')","typeGuard":null,"tryCatchPattern":"try:\n    cls = getattr(webdriver, name)\nexcept AttributeError as e:\n    if 'has no attribute' in str(e):\n        # check __dir__() or import from full path\n        from selenium.webdriver.common.by import By\n    else:\n        raise","preventionTips":["Use webdriver.__dir__() or consult __init__.py _LAZY_IMPORTS for valid top-level names.","Import non-top-level classes from their full module path.","Avoid typos by using IDE autocomplete or copy-paste from docs."],"tags":["python","imports","lazy-loading","attribute-error","webdriver"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}