【发布时间】:2013-01-06 23:47:45
【问题描述】:
我在让 Selenium 加载 chrome 配置文件时遇到了一些麻烦。
String pathToChrome = "driver/chromedriver.exe";
System.setProperty("webdriver.chrome.driver", pathToChrome);
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
String chromeProfile = "C:\\Users\\Tiuz\\AppData\\Local\\Google\\Chrome\\User Data\\Default";
ArrayList<String> switches = new ArrayList<String>();
switches.add("--user-data-dir=" + chromeProfile);
capabilities.setCapability("chrome.switches", switches);
WebDriver driver = new ChromeDriver(capabilities);
driver.get("http://www.google.com");
它开始很好并且运行完美,但我想加载默认配置文件,因为我想在启用一些扩展和测试一些首选项的情况下对其进行测试。
有人知道为什么这段代码不起作用吗?
我已经在 Windows 7 x64 上使用 Selenium 2.29.1 和 2.28.0 和 chromedriver 26.0.1383.0 对其进行了测试。
【问题讨论】:
-
嗨,你能指导我看一个教程,关于如何做到这一点 - 如何为你的驱动程序添加 chrome 配置文件?非常感谢!
标签: java google-chrome profile selenium-webdriver