【问题标题】:Python - Selenium - gecko driver + extensionsPython - Selenium - gecko 驱动程序 + 扩展
【发布时间】:2016-11-29 23:04:49
【问题描述】:

Selenium + Firefox + 扩展用于今天早些时候工作。但是我更新了 FF 并且 selenium 不再工作(see here)所以我不得不切换到 geckodriver。

我想运行 selenium (gecko 驱动) + 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 配置文件,在该配置文件中添加扩展名并使用该配置文件,创建新的 firefox 配置文件,您可以按照我在这篇文章中提到的步骤进行操作-stackoverflow.com/questions/40878504/…

标签: python selenium firefox


【解决方案1】:

让它工作:

firefox_capabilities['firefox_profile'] = profile.encoded
browser = webdriver.Firefox(capabilities=firefox_capabilities)

【讨论】:

    猜你喜欢
    • 2017-06-03
    • 1970-01-01
    • 2016-06-21
    • 1970-01-01
    • 1970-01-01
    • 2018-10-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多