3

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

from selenium import webdriver
driver = webdriver.Firefox()

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

4

2 回答 2

2

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

profile = FirefoxProfile("path.to.profile")
driver = webdriver.Firefox(profile)
于 2012-09-13T08:21:48.567 回答
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);
于 2012-09-14T08:10:30.507 回答