尝试使用Selenium 2打开已安装的Firefox插件,但始终会使用默认的Firefox配置文件并具有预定义的首选项。
from selenium import webdriver
driver = webdriver.Firefox()
上述代码行使用默认配置启动火狐浏览器。 如何使其使用用户指定的偏好设置启动?
尝试使用Selenium 2打开已安装的Firefox插件,但始终会使用默认的Firefox配置文件并具有预定义的首选项。
from selenium import webdriver
driver = webdriver.Firefox()
您可以使用类似以下方式,使用自定义配置文件启动它:
profile = FirefoxProfile("path.to.profile")
driver = webdriver.Firefox(profile)
无需设置配置文件,它可以自动创建,您只需要指定插件的路径,例如:
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);