我是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浏览器启动正常,但没有配置的插件,我的设置或书签。我应该怎么做才能使其加载这些?谢谢。
您应该先阅读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);