TesterHQ - The Evil Tester Blog Aggregator

Oct 14, 2016 - 3 minute read - Selenium Simplified Blog WebDriver

Upgrading to Selenium 3 with My First Selenium Project

Original Blog Posting on [SeleniumSimplified.com]

TLDR; set version to 3.0.1, stop using MarionetteDriver, download geckodriver v 0.11.1

Selenium 3 is out and you can read the big announcement.

You can also start to use it.

I’ll be checking my course against Selenium 3 later today, but for the moment, here are the steps you need to take to upgrade.

Upgrading to Selenium 3.0

Using startUsingSeleniumWebDriver as an example.

Change the pom.xml

        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>2.53.1</version>
        </dependency>

Becomes:

        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.0.1</version>
        </dependency>

Tadah!

Not quite Tadah

For Marionette, we need to update to the most recent version.

https://github.com/mozilla/geckodriver/releases

At the time of writing - version 0.11.1

With Selenium 3, MarionetteDriver is deprecated.

My test MyFirstTestFF48 uses MarionetteDriver.

I can see that MarionetteDriver is deprecated

But it still works, provided I have Marionette geckodriver setup correctly.

It works if I install v 0.11.1 of Marionette Driver and have it named as geckodriver.exe on the path. But I should migrate away from using MarionetteDriver in my code because it is deprecated.

Back to FirefoxDriver

FirefoxDriver now defaults to use the Marionette driver.

So I can use Marionette by running my FirefoxDriver test.

Which uses FirefoxDriver

Selenium 3, by default.

  • FirefoxDriver now uses Marionette.
  • No longer have to rename geckodriver.exe to wires.exe
  • now use geckodriver.exe

If you want to switch between 2.53.1 and 3.0.1 I’d add the Marionette driver folder to the path and:

  • have v 0.9.0 named as wires.exe
  • have v 0.11.1 named as geckodriver.exe

My firefox test:

mvn test -Dtest=MyFirstTest

Works if I install v 0.11.1 of Marionette Driver and have it named as geckodriver.exe on the path and I use FirefoxDriver to instantiate the driver.

Firefox Marionettte Summary:

To use Marionette geckodriver.exe for Firefox with Selenium 3:

Legacy Firefox?

What if you want to use the built in FirefoxDriver e.g. for Firefox Extended Support Release or portable Firefox?

Well, you still can, you just have to:

  • set the Firefox driver capability “marionette” to false
  • set the firefox_binary capability to the path of your legacy firefox

e.g.

DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette", false);
capabilities.setCapability("firefox_binary",
       new File(System.getProperty("user.dir"),
       "/tools/FirefoxPortable/FirefoxPortable.exe").
              getAbsolutePath());
WebDriver driver = new FirefoxDriver(capabilities);

Work to do

I have some work to do to update the startUsingSeleniumWebDriver and check my course tests against Selenium 3. If I have to update anything I’ll blog about it here.

Summary

  • Update pom.xml to use <version>3.0.0</version>
  • download the latest version of geckodriver.exe
  • add geckodriver.exe to the path
  • use FirefoxDriver in your code
  • set "marionette" capability to false if we want to use legacy FirefoxDriver