我试图下载新的Chrome驱动程序并将其添加到我的驱动程序文件夹中,它仍然会抛出相同的错误。
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class gmail {
public static void main(String[] args) {
WebDriver driver = new ChromeDriver();
driver.get("https://mail.google.com");
driver.findElement(By.id("Email")).sendKeys("********");
driver.findElement(By.id("next")).click();
driver.findElement(By.id("Passwd")).sendKeys("********");
driver.findElement(By.id("signIn")).click();
}
}
Error displayed:
Exception in thread "main" 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:197)
答案 0 :(得分:0)
System.setProperty("webdriver.chrome.driver", "location/of/chromedriver/in/system");
WebDriver chromeDriver = new ChromeDriver();