Selenium 2.53.0 firefox bugging

2020-04-21 05:50发布

问题:

So, when I try to open firefox like it either pops up really quickly, or it just stays there for a second until I can see it then crashes Also, I use selenium version 2.53.1

    WebDriver driver = new FirefoxDriver();
    driver.get("http://stackoverflow.com");

回答1:

Just like the other drivers available to Selenium from other browser vendors, Mozilla has released an executable geckodriver that will run alongside the browser.

You need to download latest executable geckodriver from here and set this downloaded path from your machine as system property to run your test case with Firefox driver as below :

 System.setProperty("webdriver.gecko.driver","path/to downloaded/geckodriver.exe");
 DesiredCapabilities capabilities = DesiredCapabilities.firefox();
 capabilities.setCapability("marionette", true);
 WebDriver driver = new FirefoxDriver(capabilities);
  driver.get("http://stackoverflow.com");