【发布时间】:2021-08-08 10:02:32
【问题描述】:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class Locators {
public static void main(String ars[]) throws InterruptedException {
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://www.google.com");
Thread.sleep(5000);
driver.close();
}
}
收到此错误...
> Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable The path to the driver executable必须 > 由 webdriver.chrome.driver 系统属性设置;更多 > 信息,请参阅 >https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver。最新的 > 版本可以从 > http://chromedriver.storage.googleapis.com/index.html > 在 org.openqa.selenium.internal.Require$StateChecker.nonNull(Require.java:280) > 在 org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:142) > 在 org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:37) > 在 org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:222) > 在 org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:419) > 在 org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:119) > 在 org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:41) > 在 Selenium.SeleniumPrograms.Locators.main(Locators.java:10)
【问题讨论】:
-
我使用的是 Maven,所以我还需要配置 setproperty 吗?