Skip to content

Selenium Python - Passing firefox_profile arg doesn't seem to take effect #7677

@lexotero

Description

@lexotero
  • selenium==3.141.0 Python package.
  • Firefox version 69.0.3 (64bits)
  • geckodriver 0.25.0

I am trying to launch launch a Firefox browser with an extension installed. I am using the following code:

from selenium import webdriver

profile = webdriver.FirefoxProfile()
profile.add_extension("/path/to/extension.xpi")
driver = webdriver.Firefox(firefox_profile=profile)

Now, the Firefox window that pops up doesn not have the extension installed. When I look in "about:support", I can see that the "Profile folder" is different than the one I can see in Python with driver.profile.path. In fact, checking the geckodriver.log I can see (not full log output for readability):

INFO	Running command: "firefox-bin" "-marionette" "-foreground" "-no-remote" "-profile" "/path/to/profile-A"
WARN	addMetadata: Add-on id-of-my-extension is invalid: Error: File /path/to/profile-A/extensions/id-of-my-extension does not contain a valid manifest(resource://gre/modules/addons/XPIInstall.jsm:671:11) JS Stack trace: loadManifest@XPIInstall.jsm:671:11
[...]

As you can see, the Firefox command has a -profile argument, but "/path/to/profile-A" is not the path to the profile I created with Python (let's call it /path/to/profile-B). Nevertheless it does try to load the extension from "profile-A", but the thing is that the extension is not present in that path but in the path to "profile-B".

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-pyPython Bindings

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions