Selenium 3.0: What Changed and Upgrade Guide
Selenium 3.0, released in October 2016, was a major milestone that replaced the original Selenium RC with WebDriver as the core automation engine, introduced W3C WebDriver standardization, and changed how browser drivers are managed. Upgrading from Selenium 2.x is mostly straightforward, but you need to update your dependencies, replace a few deprecated classes, and ensure your browser drivers (like chromedriver or geckodriver) are present and compatible. This article explains the key differences and provides a step-by-step upgrade path.
Background: From Selenium RC to WebDriver
Selenium started as a JavaScript-based testing tool (Selenium Core) and later added Selenium RC (Remote Control), which injected JavaScript into the browser to simulate user actions. RC had limitations: it required a separate server, was slower, and could not handle some modern browser features. WebDriver, originally a separate project by Simon Stewart, took a different approach—it controlled the browser through the browser’s native automation interface, making tests faster and more reliable. Selenium 2 merged the two, but RC remained the default. Selenium 3 finally made WebDriver the default and deprecated RC.
Key Changes in Selenium 3.0
- WebDriver is now the default: The
Selenium-RCAPI is deprecated and will be removed in Selenium 4. You should migrate any remaining RC tests. - W3C WebDriver standardization: Selenium 3 aligns with the W3C WebDriver specification, meaning that browser vendors (Chrome, Firefox, etc.) implement WebDriver natively. This improves consistency and removes the need for the Selenium server in many cases.
- Browser driver binaries are separate: In Selenium 2, you often used the Selenium Server to launch browsers. In Selenium 3, you must download and manage the appropriate driver executable (chromedriver, geckodriver, etc.) for each browser.
- New
OptionsandCapabilitiesclasses: The oldDesiredCapabilitiesis deprecated in favor of theMutableCapabilitiesand browser-specificOptionsclasses. - Improved Firefox support: Selenium 3 supports Firefox via geckodriver (Mozilla’s WebDriver implementation). The older FirefoxDriver extension is no longer supported.
- Java 8 required: Selenium 3 requires Java 8 for Java users; Selenium 2 supported Java 7.
- New
ExpectedConditionsandFluentWaitimprovements: Some methods were added, and theExpectedConditionsclass gained new conditions likenumberOfWindowsToBe.
How to Upgrade from Selenium 2 to 3
- Update your dependencies: If you use Maven, change the selenium-java version to 3.141.59 (the last 3.x release) or a later 3.x. For other languages, update the corresponding package (e.g., pip install selenium==3.141.0).
- Remove Selenium RC code: Replace any
DefaultSeleniumorSeleniuminstances withWebDriver. For example,new DefaultSelenium("localhost", 4444, "*firefox", "http://example.com")becomesnew FirefoxDriver(). - Update capabilities: Replace
DesiredCapabilitieswith browser-specificOptions. For example, in Java:FirefoxOptions options = new FirefoxOptions(); options.setHeadless(true); WebDriver driver = new FirefoxDriver(options); - Download the correct driver: For Chrome, download chromedriver and set its path via
System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver")or use WebDriverManager. For Firefox, download geckodriver and setwebdriver.gecko.driver. - Run your tests: Run a small test suite to catch any remaining API differences. Most Selenium 2 tests will work with minimal changes.
- Migrate from the Selenium Server if you used it: If you used the Selenium Server for grid, you can still use it, but you must specify the driver via capabilities. For local testing, you no longer need the server.
Common Problems During Upgrade
- Driver not found: The most common issue is that the browser driver is not in the system PATH. Ensure the driver executable is in PATH or set the system property.
- Firefox issues: Selenium 3 requires geckodriver, and Firefox versions must be compatible. If you get a “Cannot find firefox binary” error, set the binary path via
FirefoxOptions.setBinary("/path/to/firefox"). - Chrome options not working: In Selenium 2, you might use
DesiredCapabilities.chrome(). In Selenium 3, useChromeOptionsand set capabilities viaoptions.setCapability. - Deprecated API warnings: You’ll see deprecation warnings for
DesiredCapabilities,WebDriverExceptionconstructors, andFluentWaitmethods. Replace them with the recommended alternatives. - Wait methods changed:
ExpectedConditions.titleIs()is still there, but some methods likeExpectedConditions.visibilityOfElementLocated()now throwStaleElementReferenceExceptionmore often. UseFluentWaitwithignoringto handle it.
Comparing Selenium 2 vs 3
Selenium 2 and 3 are similar in API, but the internal architecture changed. In Selenium 2, the WebDriver commands were sent to the Selenium Server, which then translated them to the browser. In Selenium 3, the driver communicates directly with the browser via the WebDriver protocol (W3C). This reduces latency and improves stability. Also, Selenium 3 removed the old Selenium RC server, so you cannot run RC tests anymore. The performance is generally better, and the codebase is cleaner.
Is Selenium 3 Still Relevant?
Selenium 3 is now outdated; Selenium 4 was released in 2021 and includes many improvements like relative locators, better window/tab management, and full W3C compliance. For new projects, use Selenium 4. However, if you have a legacy test suite on Selenium 3, upgrading to 4 is also straightforward—most code will work with minimal changes. If you are starting fresh, skip 3 and go to 4.
Frequently Asked Questions
Do I need to install the Selenium Server for Selenium 3?
No, for local testing you do not need the Selenium Server. You just need the browser driver (e.g., chromedriver). The server is only needed for Selenium Grid (remote execution).
What is the difference between chromedriver and geckodriver?
Chromedriver is the WebDriver implementation for Chrome, and geckodriver is for Firefox. Each browser has its own driver that translates WebDriver commands to the browser’s native automation protocol.
Can I use Selenium 3 with Internet Explorer?
Yes, but you need the IEDriverServer. However, IE is deprecated, and it is recommended to use Edge in IE mode or switch to modern browsers.
How do I set the browser driver path in Selenium 3?
You can set the system property in Java: System.setProperty("webdriver.chrome.driver", "path/to/chromedriver"). Alternatively, use WebDriverManager to automatically download and set the driver.
Will my Selenium 2 tests work in Selenium 3?
Most will, but you may need to update imports (e.g., org.openqa.selenium.firefox.FirefoxDriver is still the same) and replace any RC-specific code. Also, update your waits and capabilities to avoid deprecation warnings.
What is the latest version of Selenium 3?
The last release of Selenium 3 was 3.141.59 (for Java) and 3.141.0 for Python. After that, development moved to Selenium 4.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.