Java 驱动程序路径不正确?我做错了什么
我试图使用selenium和java来测试登录表单,我发现了这个错误,有什么想法吗Java 驱动程序路径不正确?我做错了什么,java,selenium,selenium-webdriver,Java,Selenium,Selenium Webdriver,我试图使用selenium和java来测试登录表单,我发现了这个错误,有什么想法吗 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/SeleniumH
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:847)
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:134)
at org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:35)
at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:159)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:355)
at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:94)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123)
at com.selenium.Main.main(Main.java:11)
如果你想实例化chrome,为什么不使用chrome驱动程序呢?gecko特别针对Mozilla,您可以尝试新的FirefoxDriver();如果你想实例化chrome,为什么不使用chrome驱动程序呢?gecko特别针对Mozilla,您可以尝试新的FirefoxDriver();
package com.selenium;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
public class Main {
public static void main(String[] args) throws InterruptedException {
//Cambia la ruta del teu directori perque funcioni//
System.setProperty("webdriver.gecko.driver","C:\\Users\\Sethei\\Desktop\\M05_Selenium\\geckodriver.exe");
//Test login
WebDriver driver = new ChromeDriver();
driver.get("http://127.0.0.1:8000/login");
driver.manage().window().maximize();
driver.findElement(By.id("email")).sendKeys("email@gmail.com");
driver.findElement(By.id("password")).sendKeys("12345678");
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
driver.findElement(By.id("login")).click();
Thread.sleep(3000);