Python - Selenium - 壁虎驱动程序+扩展
问题描述:
Selenium + Firefox +扩展用于今天早些时候工作。但我更新FF和硒不再工作(see here),所以我不得不切换到geckodriver。Python - Selenium - 壁虎驱动程序+扩展
我想运行硒(壁虎驱动程序)+ udrive扩展+ quickjava扩展,就像我之前FF更新。
我有以下代码:
firefox_capabilities = DesiredCapabilities.FIREFOX
firefox_capabilities['marionette'] = True
firefox_capabilities['binary'] = '/usr/bin/firefox'
global browser
profile = webdriver.FirefoxProfile()
profile.add_extension("IN/quickjava-2.0.6-fx.xpi")
profile.add_extension("IN/ublock184.xpi")
profile.set_preference("thatoneguydotnet.QuickJava.curVersion", "2.0.6.1") ## Prevents loading the 'thank you for installing screen'
profile.set_preference("thatoneguydotnet.QuickJava.startupStatus.Images", 2) ## Turns images off
profile.set_preference("thatoneguydotnet.QuickJava.startupStatus.AnimatedImage", 2) ## Turns animated images off
browser = webdriver.Firefox(capabilities=firefox_capabilities, firefox_profile=profile)
但是Firefox启动和运行,而无需任何扩展的,为什么?
答
制造它的工作:
firefox_capabilities['firefox_profile'] = profile.encoded
browser = webdriver.Firefox(capabilities=firefox_capabilities)
只需通过创建一个新的Firefox配置文件一次尝试,在配置文件中添加扩展名并使用该配置文件,创建新的Firefox配置文件,您可以按照我所提到的步骤这篇文章 - http://stackoverflow.com/questions/40878504/how-to-use-acceptsslcerts-with-remotewebdriver/40881502#40881502 –