3
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

スレッド「メイン」での例外 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) at com.merchantPlatform.MerchantPlatformTest.main(MerchantPlatformTest.java:20)

4

2 に答える 2