package com.merchantPlatform;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
public class MerchantPlatformTest {
public static void main(String[] args) {
System.getProperty("webdriver.gecko.driver", "C:\\Selenium WebDriver\\geckodriver\\geckodriver-v0.17.0-win64\\geckodriver.exe");
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
// Initialize WebDriver
WebDriver driver = new FirefoxDriver(capabilities);
/* This works fine for versions lesser than Selenium 3. For Selenium 3 and higher, it will throw java.lang.IllegalStateException */
// Maximize Window
driver.manage().window().maximize();
// Wait For Page To Load
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
// Navigate to MerchantPlatform URL
driver.get("http://localhost:52939/");
}
}
错误
我收到以下异常System.getProperty
线程“main”中的异常 java.lang.IllegalStateException:驱动程序可执行文件的路径必须由 webdriver.gecko.driver 系统属性设置;有关更多信息,请参阅 https://github.com/mozilla/geckodriver。最新版本可以从https://github.com/mozilla/geckodriver/releases下载 在 com.google.common.base.Preconditions.checkState(Preconditions.java:738) 在 org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:124) 在 org.openqa.selenium.firefox.GeckoDriverService org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService. java:330) 在 org.openqa.selenium.firefox.FirefoxDriver.toExecutor(FirefoxDriver.java:207) 在 org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:108) 在 org.openqa.selenium.firefox。 FirefoxDriver.(FirefoxDriver.java:137) 在 com.merchantPlatform.MerchantPlatformTest.main(MerchantPlatformTest.java:20)