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

后端 未结 5 967
[愿得一人]
[愿得一人] 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:56

    you are using user.dir that basically means : current working directory

    Here is the code that let you initialize firefox browser using selenium.

    public static void main(String[] args) {
    
    
                System.setProperty("webdriver.gecko.driver", "C:\\your\\gecko\\driver\\path\\geckodriver.exe");
                driver = new firefoxDriver();
    

    That's it ! you can use Firefox driver to performs several operations like :

    1.  driver.get(String args0);
    2.  driver.getCurrentUrl();
    3.  driver.getPageSource();
    4.  driver.getTitle();
    5.  driver.findElememt(By args0);
    6.  driver.findElements(By args0);
    7.  driver.naviagate();
    8.  driver.manage();
    9.  driver.close();
    10. driver.quit();
    11. driver.switchTo();
    12. driver.getWindowHandle();
    13. driver.getWindowHandles();
    

    Please let me know if you have any concerns related to this.

提交回复
热议问题