new ChromeDriver
上一篇 /
下一篇 2012-04-13 14:28:20
/ 个人分类:selenium2
报错:Exception in thread "main" java.lang.IllegalStateException: The path to the chromedriver executable must be set by the webdriver.chrome.driver system property; for more information, see http://code.google.com/p/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://code.google.com/p/chromium/downloads/listat com.google.common.base.Preconditions.checkState(Preconditions.java:172)at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:85)at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:87)at ch.test5.main(test5.java:18)
之前也遇到了类似问题,是由于没有安装chromedriver造成的,
在http://code.google.com/p/chromium/downloads/list上下载最新的chromedriver.exe,
并且在代码中加入System.setProperty("webdriver.chrome.driver",path);WebDriver driver = new ChromeDriver(); 其中path是chromedriver的存放路径,如:C:\\Users\\xxx\\AppData\\Local\\Google\\Chrome\\Application\\chromedriver.exe,
或者直接将chromedriver的存放路径配在系统的环境变量里,如:C:\\Users\\xxx\\AppData\\Local\\Google\\Chrome\\Application,脚本中直接用WebDriver driver = new ChromeDriver();启动,
收藏
举报
TAG: