SeleniumHQ/selenium · warning · AttributeError

module {__name__!r} has no attribute {name!r}

Error message

module {__name__!r} has no attribute {name!r}

What it means

Raised by the module-level __getattr__ in selenium.webdriver.firefox when an attribute access does not match one of the lazily-imported submodules (firefox_profile, options, remote_connection, service, webdriver). Identical lazy-import pattern to the edge package; only those five names auto-resolve, anything else raises AttributeError.

Source

Thrown at py/selenium/webdriver/firefox/__init__.py:28

#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

import importlib

_LAZY_SUBMODULES = ["firefox_profile", "options", "remote_connection", "service", "webdriver"]


def __getattr__(name):
    if name in _LAZY_SUBMODULES:
        module = importlib.import_module(f".{name}", __name__)
        globals()[name] = module
        return module
    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")


def __dir__():
    return sorted(_LAZY_SUBMODULES)

View on GitHub (pinned to aa36b38e69)

Solutions

  1. Check the spelling against _LAZY_SUBMODULES: firefox_profile, options, remote_connection, service, webdriver.
  2. Access classes through their submodule: from selenium.webdriver.firefox.options import Options.

Example fix

# before
from selenium.webdriver.firefox import profile  # -> AttributeError

# after
from selenium.webdriver.firefox import firefox_profile
Defensive patterns

Strategy: validation

Validate before calling

from selenium.webdriver import firefox
_VALID = {'firefox_profile','options','remote_connection','service','webdriver'}
assert name in _VALID, f'{name!r} is not a firefox submodule'

Type guard

null

Try / catch

null

Prevention

When it happens

Trigger: Accessing selenium.webdriver.firefox.SomeName not in _LAZY_SUBMODULES — e.g. a typo like 'profile' instead of 'firefox_profile', or expecting a top-level class re-export like selenium.webdriver.firefox.Options (must be selenium.webdriver.firefox.options.Options).

Common situations: Typing the submodule name, IDE auto-complete picking a wrong suggestion, or 'from selenium.webdriver.firefox import X' where X is not a known submodule. Common confusion is using 'profile' instead of 'firefox_profile'.

Related errors


AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14). Data as JSON: /api/errors/bcdb12e920f08d66. Report an issue: GitHub.