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.