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
- Check the spelling against _LAZY_SUBMODULES: firefox_profile, options, remote_connection, service, webdriver.
- 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
- Import classes from their submodule: firefox.options.Options.
- Remember the profile submodule is named firefox_profile, not profile.
- Use IDE navigation rather than guessing top-level re-exports.
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
- module {__name__!r} has no attribute {name!r}
- Couldn't find manifest.json in ${extension}
- Could not find add-on ID for ${extension}
- CDP support for Firefox is removed. Please switch to WebDriv
- Port needs to be an integer
AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14).
Data as JSON: /api/errors/bcdb12e920f08d66.
Report an issue: GitHub.