2014-08-30 50 views
1

我使用this插件與硒,它開始罰款,但你如何去影響硒的插件設置?配置RefControl擴展使用硒webdriver

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

profile = FirefoxProfile('/path/to/profile') 
driver = webdriver.WebDriver(firefox_profile = profile) 
driver.get("http://localhost/referer.html") 
driver.find_element_by_link_text("go there").click() 

的問題是,這個插件不會做任何事情,除非你先對其進行配置,但沒有文件,我可以找到關於這一點。

+1

如果您先安裝並配置擴展名,然後在硒中使用該Firefox配置文件,該怎麼辦? – alecxe 2014-08-30 23:01:48

回答

2

正如alecxe建議的那樣,「先安裝和配置擴展,然後在硒上使用該firefox配置文件」。這可能適用於任何擴展。

我還在prefs.js(或about:conf)中搜索配置,並發現它將值存儲在「refcontrol.actions」首選項中。通過這種方式,您將能夠更改代碼中的擴展行爲。例如:

profile = FirefoxProfile('/path/to/profile') 
profile.set_preference("refcontrol.actions", '@[email protected] [email protected]:http://www.referer.com/your/referer'); 
+0

感謝分享! – alecxe 2014-08-30 23:46:56

+0

分享=很棒 – Noitidart 2014-08-30 23:48:07