Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium, how to start Firefox with addons?

I want to load the Firefox Addon RequestPolicy. This is how i tried it:

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()

No error, according to the Docs it should work, but it doesn't, it still starts without the addon.

Next thing i've tried is calling it this way:

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

Output:

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

But this is an aspect of python i dont know much about. I got that idea because the source looks that way.

like image 985
jgillich Avatar asked Sep 19 '11 22:09

jgillich


People also ask

How can the Add-ons be added to selenium?

All you need to do is download your extension as . xip file. Replace "/Users/someuser/app/extension. xpi" with path to your extension .


1 Answers

I don't have enough Stackoverflow rep to leave a comment on your question, and unfortunately I don't know the answer to your question, but for what it's worth you need to call webdriver.Firefox() with firefox_profile, not browser_profile, as you have done.

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

like image 101
ampledata Avatar answered Nov 03 '22 04:11

ampledata