我的代码非常简单:
package Automation;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class FirstTestCase {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.setProperty("webdriver.chrome.driver","/Users/Jagman/Downloads/chromedriver");
WebDriver wd = new ChromeDriver();
String url = ("https://www.google.com/");
wd.get(url);
已经从selenium hq网站下载并添加了jar作为"Java 3.13.0"。从同一网站下载Google Chrome Driver-2.29,并将其定位在"/Users/Jagman/Downloads/chromedriver"路径中。
当我运行上面的代码时,我得到一个错误为"java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html at com.google.common.base.Preconditions.checkState(Preconditions.java:738)".
尽管配置正确,但获取版本错误。所以请帮我解决这个问题。详细信息:操作系统:Mac。
在chromedriver路径中添加.exe:
System.setProperty("webdriver.chrome.driver","/Users/Jagman/Downloads/chromedriver.exe");