SeleniumHQ/selenium · error · OSError
Add-on path does not exist: {addon_path}
Error message
Add-on path does not exist: {addon_path} What it means
Raised by FirefoxProfile's add-on manifest parser when the addon_path passed to it does not exist on the filesystem (os.path.exists returns False). The library validates the path before attempting any zip or directory read, so the user gets a clear error instead of a cryptic downstream failure.
Source
Thrown at py/selenium/webdriver/firefox/firefox_profile.py:275
rc.append(node.data)
return "".join(rc).strip()
def parse_manifest_json(content):
"""Extract details from the contents of a WebExtensions manifest.json file."""
manifest = json.loads(content)
try:
id = manifest["applications"]["gecko"]["id"]
except KeyError:
id = manifest["name"].replace(" ", "") + "@" + manifest["version"]
return {
"id": id,
"version": manifest["version"],
"name": manifest["version"],
"unpack": False,
}
if not os.path.exists(addon_path):
raise OSError(f"Add-on path does not exist: {addon_path}")
try:
if zipfile.is_zipfile(addon_path):
with zipfile.ZipFile(addon_path, "r") as compressed_file:
if "manifest.json" in compressed_file.namelist():
return parse_manifest_json(compressed_file.read("manifest.json"))
manifest = compressed_file.read("install.rdf")
elif os.path.isdir(addon_path):
manifest_json_filename = os.path.join(addon_path, "manifest.json")
if os.path.exists(manifest_json_filename):
with open(manifest_json_filename, encoding="utf-8") as f:
return parse_manifest_json(f.read())
with open(os.path.join(addon_path, "install.rdf"), encoding="utf-8") as f:
manifest = f.read()
else:
raise OSError(f"Add-on path is neither an XPI nor a directory: {addon_path}")View on GitHub (pinned to aa36b38e69)
Solutions
- Verify the path exists with os.path.exists(addon_path) before calling the API
- Use an absolute path constructed with os.path.abspath or pathlib.Path.resolve()
- Ensure the .xpi or addon directory is present in CI by checking it into the repo or downloading it as a build step
Example fix
// before
profile.add_extension('addons/myplugin')
// after
import os
addon = os.path.abspath('addons/myplugin')
assert os.path.exists(addon), f'Addon not found at {addon}'
profile.add_extension(addon) Defensive patterns
Strategy: validation
Validate before calling
import os
addon_path = 'addons/myplugin.xpi'
if not os.path.exists(addon_path):
raise FileNotFoundError(f'Addon path does not exist: {addon_path}')
profile.add_extension(addon_path) Try / catch
try:
profile.add_extension(addon_path)
except OSError as e:
print(f'Addon path invalid: {e}')
addon_path = resolve_addon_path() # fallback logic Prevention
- Use absolute paths constructed with os.path.abspath
- Verify file existence with os.path.exists before calling
- Ensure addon files are present in CI by copying them as a build step
When it happens
Trigger: Calling the add-on install/parse API with a path to an .xpi file or directory that does not exist, a relative path resolved from the wrong working directory, or a typo in the path string.
Common situations: Relative paths that break when tests run from a different CWD. CI environments where addon files are not copied into the working tree. Paths with typos or wrong file extensions.
Related errors
- Add-on path is neither an XPI nor a directory: {addon_path}
- {str(e)}
- Add-on id could not be found.
- could not find extension at #{path.inspect}
- Couldn't find manifest.json in ${extension}
AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14).
Data as JSON: /api/errors/a505e1e49e240290.
Report an issue: GitHub.