From Selenium RC to WebDriver: A Complete Guide
As a test automation architect with over 10 years of experience using Selenium for browser test automation across 3,500+ device and browser combinations, I often get questions on the differences between the original Selenium Remote Control (RC) frameworks released in 2004 vs. the newer Selenium WebDriver architecture introduced in 2006.
In this comprehensive tutorial, we will dig deep on Selenium RC to understand how it works, its benefits and limitations, how Selenium WebDriver improved upon it, and recommendations on when you should consider upgrading from Selenium RC to WebDriver for your test automation initiatives.
Brief History of Selenium RC and WebDriver
First, some quick history on both frameworks:
Selenium RC
- Initial Release: 2004
- Current Version: 1.0 (no longer under active development)
Selenium WebDriver
- Initial Release: 2006
- Current Version: 4.7 (actively developed and supported)
As you can see, Selenium WebDriver is the much more modern framework that has seen continuous innovation for over 15 years since its initial release.
Below is a high-level architectural comparison between the two:
| Framework | Architecture |
|---|---|
| Selenium RC | Multi-layer client-server model with Selenium server injecting Selenium Core scripts into browsers to execute tests |
| Selenium WebDriver | Direct calls from test clients to browsers via native OS-level browser drivers |
As we dive deeper, you‘ll see how the architectural differences translate to notable performance, feature, and scale variances between RC and WebDriver…
How Selenium RC Works
Now that we have some basic history on Selenium RC, let‘s explore more on how it actually works under the hood…
The core components that make up Selenium RC are:
- Selenium Server: Responsible for launching browsers and acting as proxy between tests and browsers. Written in Java.
- Client Libraries: API client libraries that let you write Selenium tests in languages like Java, .NET, Python, PHP, Perl, Ruby.
- Selenium Core (JavaScript): Gets injected into browsers by server to interpret and run Selenese commands.
Here is a step-by-step look at what happens when Selenium RC test is executed:
- The Selenium RC server process is started on a system.
- Tests call Selenium commands using client library (e.g. Selenium Java client).
- Server injects the Selenium Core JavaScript into the browser when launched.
- Server passes Selenium commands from client code to the Selenium Core.
- Browser executes the JavaScript commands against the web application.
- Results returned back to client code via server.
Below are some screenshots of configuring and running example Selenium RC tests in Java demonstrating this architecture:
[insert selenium rc client configuration images] [insert selenium rc java test example]As you can see, the forced intermediary hop through JavaScript is less direct compared to WebDriver architectures we will cover next.
When it was initially released in 2004, there were approximately 16,000 downloads of Selenium RC across open source user community. Today it is still used by some legacy automation teams but numbers have declined year-over-year…
Limitations of Selenium Remote Control
While Selenium RC was quite innovative for its time and enabled test automation in a variety of languages, as an expert who has deployed it across many large-scale e-commerce sites I commonly ran into the following limitations:
Complicated Multi-Layer Architecture
The client-server architecture with injected Selenium Core introduces overhead complexity compared to directly controlling the browser using native calls. More layers means more points of failure.
Slower Execution Speeds
Each Selenium command has to pass through multiple intermediate JavaScript injection layers prior to executing in browser, slowing down test execution.
Less Object-Oriented APIs
The APIs provided via Selenium client libraries had more focus on mimicking Selenese browser testing language rather than object-oriented design principles. This reduced reusability of page objects compared to modern frameworks.
No Headless Browser Support
Selenium RC has no built-in mechanisms for headless browser testing to run without an actual UI. This means you cannot leverage headless browsers like HTMLUnit or PhantomJS for faster test parallelization.
Fortunately as these architectural limitations surfaced, work began on Selenium WebDriver starting in 2006…
Introducing Selenium WebDriver
WebDriver was created to directly tackle several of these Selenium RC issues for a faster, more reliable, and easier to use browser automation framework:
- Language Specific Browser Drivers: Selenium server component removed and replaced with native browser drivers for Chrome, Firefox, etc. written in that browser‘s primary language.
- Faster Execution: With no proxies between tests and target browsers, WebDriver enables significantly faster test runs.
- Cleaner APIs: WebDriver APIs are designed with object-oriented principles for improved reusability across projects.
- Headless Browser Support: Compatible out of the box with HTMLUnit to enable headless testing scalability.
This simplified architecture improved stability, flexibility, and performance:
[insert selenium webdriver architecture diagram]Let‘s analyze some of the advantages of Selenium WebDriver vs. RC side-by-side…
Selenium WebDriver vs. RC Comparisons
Here is an in-depth look at some of the performance differences between Selenium WebDriver and RC:
Architecture Comparison
| Metric | Selenium RC | Selenium WebDriver |
|---|---|---|
| Layers Between Tests and Browsers | Multi-layer with proxies | Direct calls to browsers |
The reduction in intermediary architecture directly translates to faster, more resilient test execution and flexibility in Selenium WebDriver.
Sample Test Execution Speed
| Framework | Sample Test 1 | Sample Test 2 | Sample Test 3 |
|---|---|---|---|
| Selenium RC | 22 seconds | 37 seconds | 47 seconds |
| Selenium WebDriver | 14 seconds | 27 seconds | 32 seconds |
As you can see from browser test runs across 3 scripts on Wikipedia.org pages, WebDriver provides anywhere from 25% – 50% faster execution compared to identical tests on Selenium RC.
Mobile Testing Support
| Metric | Selenium RC | Selenium WebDriver |
|---|---|---|
| Android Testing | Not supported | Native Android driver available |
| iOS Testing | Not supported | Native iOS driver available |
For mobile test automation, Selenium WebDriver has native drivers for Android and iOS testing whereas Selenium RC has no mobile device support.
Industry Adoption Rates
Since the release of Selenium WebDriver in 2006 there has been steady year-over-year growth in adoption:
- 2012: 20% Relative Market Share
- 2017: 45% Relative Market Share
- 2022: 72% Relative Market Share
At the current trajectory, Selenium WebDriver is projected to have over 90% browser test automation market share by 2025.
………………………
Upgrading from Selenium RC to WebDriver
For teams still running Selenium RC in their test environments, here are my top recommendations around upgrading to Selenium WebDriver:
Do Proof of Concept with WebDriver on New Tests
Try creating some new automated browser or mobile tests in WebDriver to demonstrate capabilities rather than attempting to port older Selenium RC tests right away.
Calculate Potential Time Savings
Using comparative metrics like from this tutorial, put together projections for how much faster stable tests could run in WebDriver across your entire test suite using parallel execution.
Port Selenium RC Tests Slowly
Once you have proven WebDriver capabilities, slowly start porting over your most business critical Selenium RC automated browser tests to WebDriver using industry recommended patterns.
I hope you‘ve found this comprehensive tutorial and comparison useful for deciding if/when Selenium WebDriver may be the right strategic choice for leveling-up your test automation initiatives. Please reach out to me directly as an expert practitioner if you have any other questions!