我是Selenium的新用户。我想用它来启动Chrome浏览器,但我遇到了一个问题。
public static void processor(String url, String name) {
System.setProperty("webdriver.chrome.driver", "C:/Documents and Settings/jingxiong/Local Settings/Application Data/Google/Chrome/Application/chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get(url);
WebElement element = driver.findElement(By.name(name));
element.sendKeys("google");
element.submit();
System.out.println("Page title is: " + driver.getTitle());
driver.quit();
} 当我运行此示例时,Chrome浏览器启动正常,但没有配置插件、我的设置或书签。我该怎么做才能让它加载这些?谢谢。
发布于 2012-05-03 23:28:09
您应该首先阅读selenium wiki中的chromedriver文档。可在此处获取- http://code.google.com/p/selenium/wiki/ChromeDriver
正如wiki中提到的:-类似地,在Chrome启动时加载扩展:
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability("chrome.switches", Arrays.asList("--load-extension=/path/to/extension/directory"));
WebDriver driver = new ChromeDriver(capabilities);https://stackoverflow.com/questions/10425799
复制相似问题