org.openqa.selenium.SessionNotCreatedException: Unable to find a matching set of capabilities while initiating Firefox v37 through Selenium v3.11.0

后端 未结 5 962
[愿得一人]
[愿得一人] 2020-11-30 15:16

I am trying to run test a run a website in Firefox, but I am getting error \"The path to the driver executable must be set by the webdriver.gecko.driver system property;\" I

5条回答
  •  情歌与酒
    2020-11-30 15:49

    Just updated your code. You will have to set driver path while setProperty and user webdriver.gecko.driver for latest firefox driver.

        if (browsers.equalsIgnoreCase("Firefox")) {
                String driverPath = System.getProperty("user.dir") + "\\src\\test\\java\\drivers\\geckodriver.exe"; 
                System.setProperty("webdriver.firefox.driver", "driverPath"); 
                DesiredCapabilities capabilities = new DesiredCapabilities();
                capabilities.setCapability("marionette", false); 
                FirefoxOptions options = new FirefoxOptions(); 
                options.merge(capabilities);
                FirefoxDriver driver = new FirefoxDriver(options);
                driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
            } 
            else if (browsers.equalsIgnoreCase("Chrome")) {
                // String driverPath = System.getProperty("user.dir") +
                // "\\src\\Drivers\\chromedriver";
                // System.setProperty("webdriver.chrome.driver", driverPath);
                System.setProperty("webdriver.chrome.driver", "D:\\chromedriver.exe");
                driver = new ChromeDriver();
                driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
            }
    

    Let me know.

提交回复
热议问题