简体   繁体   中英

Use of Selenium 3.0 with Firefox V<47

Selenium3 supports executable geckodriver to launch Mozilla Firefox just like other drivers; but executable geckodriver is not compatible with Mozilla Firefox < v47 .

So How can we achieve backward compatibility with browsers V<47 i,e how can we use firefox browsers V<47 with Selenium3 .

Disable the geckodriver capabilities so that FirefoxDriver can be used.

System.setProperty("webdriver.gecko.driver", "path/to/geckodriver.exe");
DesiredCapabilities d = new DesiredCapabilities();
d.setCapability("marionette", false);  // to disable marionette, by default true
WebDriver driver = new FirefoxDriver(d);

Little Background to geckodriver.exe and Firefox version support:

From geckodriver github page:

Firefox 47 is explicitly not supported

So, If you want to use <= Firefox 47 version, use Firefox driver but not geckodriver .

  1. In case of selenium 2.53, you don't need to do any additional things (no need to setup geckodriver as selenium 2.53 uses Firefox driver by default ).
  2. In Selenium 3.0, we must set geckodriver path (as geckodriver is the default driver for Firefox in Selenium 3.0 ) using System.setProperty and set marionette to false , so geckodriver capabilities will be disabled and default Firefox driver is used.

References:

  1. https://github.com/mozilla/geckodriver#supported-firefoxen
  2. https://github.com/mozilla/geckodriver/issues/224
  3. https://stackoverflow.com/a/40658421/2575259

You should use old FirefoxDriver , just make sure to set marionette on false if you are using RemoteDriver because I'm not sure is it enabled by default ( caps.setCapability(FirefoxDriver.MARIONETTE, false); )

This driver doesn't need any .exe file, just import org.openqa.selenium.firefox.FirefoxDriver; in your code so you could use it.

driver = new FirefoxDriver();

or if you are using grid:

driver = RemoteWebDriver(url, DesiredCapabilities.firefox());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM