l0b0
l0b0

Reputation: 58908

How to install add-on on a remote Firefox webdriver?

install_addon is a method on the Firefox webdriver, but I'm running tests remotely. How can I install an add-on to a driver like the following:

driver = webdriver.Remote(
    command_executor=SELENIUM_URL,
    desired_capabilities=webdriver.DesiredCapabilities.FIREFOX
)

? It looks like creating a webdriver.FirefoxProfile() and using add_extension() should work, but it's currently broken.

The use case is testing the effect of Firefox add-on manifest.json's all_frames property.

Upvotes: 1

Views: 325

Answers (1)

FieryDruid
FieryDruid

Reputation: 11

Аfter a long search and visits on this topic from google i found solution

Install addon in you Firefox profile from browser, save it and set him into webdriver options.

Firefox profile creating

  1. Open you firefox browser
  2. Go to about:profiles
  3. Create a New Profile
  4. Launch browser with created profile
  5. Install addons what you need

Export profile

  1. Open root directory of your firefox profile (see in in about:profiles in Root Directory section)
  2. Copy folder into you project

Python

from selenium.webdriver import FirefoxOptions, FirefoxProfile, Remote

# init options object
options = FirefoxOptions()

# init profile object with path to you profile
profile = FirefoxProfile('{path_to_your_profile_folder}')

# set profile into options
options.profile = profile

# init you Remote browser with created options (commented arguments for example)
driver = Remote(
    options=options,
    # command_executor= ..., 
    # desired_capabilities=...
)


It`s works for me. The disadvantage of this solution is the presence of a folder with a profile that needs to be stored somewhere

Upvotes: 1

Related Questions