Selenium, how to run Firefox with add-ons?

I want to download the Firefox Addon RequestPolicy. Here is how I tried:

rp = open(wd + "/requestpolicy.xpi") firefoxProfile = FirefoxProfile() firefoxProfile.add_extension(rp) self.driver = webdriver.Firefox(firefoxProfile) self.usr = user.User(self.driver, username, password, world) self.usr.login() 

There is no error, in accordance with the Documents , it should work, but this is not so, it still starts without an addon.

The next thing I tried is called like this:

 self.driver = webdriver.Firefox(browser_profile=firefoxProfile) 

Output:

 TypeError: __init__() got an unexpected keyword argument 'browser_profile' 

But this is an aspect of python that I don't know about. I got this idea because source looks like.

+4
source share
3 answers

I miss the Stackoverflow representation to leave a comment on your question, and, unfortunately, I do not know the answer to your question, but why do you need to call webdriver.Firefox() using firefox_profile and not browser_profile , as you did.

See also: http://code.google.com/p/selenium/source/browse/trunk/py/selenium/webdriver/firefox/webdriver.py#33

+4
source

what i did and worked:

 profile=webdriver.FirefoxProfile() profile.add_extension("/home/.../.mozilla/firefox/zrdb9ki8.default/extensions/{d10d0bf8-f5b5-c8b4-a8b2-2b9879e08c5d}.xpi") # for adblockplus profile.set_preference("extensions.adblockplus.currentVersion", "2.8.2") Fox = webdriver.Firefox(profile) Fox.get(website_Url) #https://..... 
+2
source

In addition, you should not open the xpi file directly. Instead, just enter the address:

 firefoxProfile.add_extension(wd + "/requestpolicy.xpi") 
0
source

All Articles