Upgrading Selenium WebDriver from v 2.40.0 to 2.42.2

A new version of Selenium WebDriver came out recently and I had to make a few changes to my main course source code as a result. I had not upgraded publicly for a while so I was moving from 2.40.0 to 2.42.2, but I had been using 2.41.0 in tutorials and workshops.

In this blog post I’m going to describe the process I went through in order to do it.

  • Amend the WebDriver version in the pom.xml
  • run a “mvn clean test-compile” to catch any compile errors after the upgrade
    • If I just use “mvn clean compile” it won’t report the errors as nothing has changed in the source code
  • fix any errors

In this case, when I jumped to 2.42.2 I encountered compile issues with the “WebDriverBackedSelenium import” and the “HTMLUnit BrowserVersion” variables.

The ultimate fixes were pretty simple, but it is really the process that is interesting.

 

Fixing the Import

I read the changelog to see if anything interesting has happened. I find this by going off to SeleniumHQ.org, clicking “download”, clicking “Browse Git”, clicking “changes”, look at the release for 2.42.2, and view the changelog.

A search for “WebDriverBackedSelenium” in the changelog reveals that in 2.40.0 it was moved to “com.thoughtworks.selenium.webdriven” and deprecated in its current import

And sure enough, when I check back to the code in 2.40.0 it is deprecated. The change log doesn’t tell me when it was removed, but I’m interested so I just change the pom.xml file to 2.41.0 and the error appears, so it was deprecated in 2.40.0 and removed in 2.41.0.

The easy way for me to fix this error is to remove the import statement and let IntelliJ find it, or I could copy the import from the change log. I let IntelliJ do it. But I make the changes against 2.42.2 rather than 2.41.0.

To make IntelliJ fix this I

  • delete the import line in the code
  • use auto fix in IntelliJ with “Intention Actions” (Alt+Enter)
  • choose the correct import from the list in IntelliJ, or let IntelliJ find it if there is only one

Fixing HTMLUnit Issue

There was no mention in the change log for the HTMLUnit issue.

When I view the code of BrowserVersion in 2.42.2 I can see that htmlunit-2.14 is in use, and in 2.40.0 it was htmlunit-2.13 so I assume it is just an upgrade of HTMLUnit that has caused my issue.

In the HTMLUnit change log I can see that they recommend FIREFOX_24 so I’ll change the code to use that.

Change Happens

With the issues fixed, I check the compile

  • “mvn clean test-compile”

And all works.

Change happens. We just have to learn how to deal with it.

Hope this, and the associated video help.

This entry was posted in Maven, Selenium Simplified Blog, WebDriver. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *