为什么我不能使用Selenium Chrome Driver

时间:2015-11-11 07:45:53

标签: selenium selenium-webdriver selenium-chromedriver

我尝试使用ChromeDrive但是收到错误或者没有成功。

我用于测试的简单java代码是:

@Test
public void testGoogleSearch() {
  System.setProperty("webdriver.chrome.driver", "lib\\chromedriver.exe");

  WebDriver driver = new ChromeDriver();
  driver.get("http://www.google.com/xhtml");
  Thread.sleep(5000);  // Let the user actually see something!
  WebElement searchBox = driver.findElement(By.name("q"));
  searchBox.sendKeys("ChromeDriver");
  searchBox.submit();
  Thread.sleep(5000);  // Let the user actually see something!
  driver.quit();
}

遵循本教程: https://sites.google.com/a/chromium.org/chromedriver/getting-started

enter image description here

2 个答案:

答案 0 :(得分:0)

<强>解决

我需要更新ChromeDrive并替换之前的ChromeDrive。 在我的项目目录/ lib

在此处下载:https://sites.google.com/a/chromium.org/chromedriver/downloads

答案 1 :(得分:0)

是的,我建议你可以这样提及C:\\Users\\mona\\Downloads\\chromedriver_win32\\chromedriver.exe