首页 文章

selenium web驱动程序无法使用自定义优先级打开firefox

提问于
浏览
3

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

from selenium import webdriver
driver = webdriver.Firefox()

上面的代码行使用默认配置文件启动firefox . 如何使用用户指定的首选项启动它?

2 回答

  • 2

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

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

    没有必要设置配置文件,它可以自动创建,你只需要添加路径,例如:

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

相关问题