我在使用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进行了测试。