【问题标题】:selenium web driver does not open firefox with custom prefrencesselenium webdriver 不使用自定义首选项打开 Firefox
【发布时间】:2012-09-13 05:05:18
【问题描述】:

尝试使用 selenium 2 打开已安装插件的 firefox,但始终使用具有预定义首选项的默认 firefox 配置文件打开

from selenium import webdriver
driver = webdriver.Firefox()

以上代码行使用默认配置文件启动 Firefox。 如何让它以用户指定的偏好启动?

【问题讨论】:

    标签: python selenium firefox selenium-webdriver


    【解决方案1】:

    您可以使用以下自定义配置文件启动它:

    profile = FirefoxProfile("path.to.profile")
    driver = webdriver.Firefox(profile)
    

    【讨论】:

      【解决方案2】:

      无需设置配置文件,可以自动创建,只需要插件的路径,例如:

              string firebugPath = "C:\\Users\\Administrator\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\x7nutq33.default\\extensions\\firebug@software.joehewitt.com.xpi";
              FirefoxProfile profile = new FirefoxProfile();       
              profile.AddExtension(firebugPath);
              Driver = new FirefoxDriver(profile);
      

      【讨论】:

        猜你喜欢
        • 2023-04-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-10-28
        • 2014-07-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多