Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python selenium import my regular firefox profile ( add-ons)

I've been trying to get my add-ons to work with my driver(driver as in webdriver.Firefox(profile)). I have no idea how to import (or if its optional at all) my regular Firefox profile. The one, i assume, contains all my add-ons.

Help is needed indeed.

Beside a solution (if available) an explanation to why my add-ons do not exist on the selenium webdriver could be a nice touch.

Thank very much!!

like image 338
Captain_Meow_Meow Avatar asked Nov 29 '13 16:11

Captain_Meow_Meow


People also ask

How do I use selenium python in Firefox?

To make Firefox work with Python selenium, you need to install the geckodriver. The geckodriver driver will start the real firefox browser and supports Javascript. Take a look at the selenium firefox code. First import the webdriver, then make it start firefox.

Does selenium work with Firefox?

Selenium IDE is an integrated development environment for Selenium tests. It is implemented as a Firefox extension, and allows you to record, edit, and debug tests.

What is the WebDriver for Firefox?

WebDriver is a remote control interface that enables introspection and control of user agents. It provides a platform- and language-neutral wire protocol as a way for out-of-process programs to remotely instruct the behavior of web browsers.


1 Answers

If you do this, and set path_to_my_profile to where your usual profile resided, then Selenium should use your profile:

from selenium import webdriver
from selenium.webdriver.firefox.webdriver import FirefoxProfile

profile = FirefoxProfile(path_to_my_profile)
driver = webdriver.Firefox(profile)

I've not done this myself but I say this based on having read the code of Selenium. The reason Selenium does not use your profile by default is that by default a FirefoxProfile object is created with None as the first argument, which means "create a new profile for the Firefox instance we're about to launch".

By the way, what Selenium does by default (creating a new profile) is the best practice to ensure the repeatability of tests. It is a good thing.

like image 179
Louis Avatar answered Oct 02 '22 00:10

Louis