Moving from Selenium RC to Webdriver

Two years ago, while working at the The Trainilne, I was part of the Automated Refunds project and the main QA/Developer for its automated test framework. The aim was to replace the existing mainly manual system and provide a transactional and fully automated refund processing system.

As this application was mainly to be used in Internet Explorer, we decided to build an automated testing framework using Selenium RC, NUNIT and C#. This testing framework was a success, with 30,000 lines of code (including coding of 120 tests) and 1650 Assertions.

My Selenium journey started way back in September 2006, while I was still at University and was doing my work placement at Volantis. The selenium RC version back then was 0.8.1 and Selenium IDE was 0.8.2. Selenium has come a long way since then and became a popular and well established testing framework that worked with a large number of browsers, allowed you to write your tests in almost any language, it was Open Source and as it was written in JavaScript, it was very easy and quick to add support for new browsers that might be released.

But it was not perfect. I took a lot of shortcuts, cut corners and did stuff in ugly/dirty ways to get things done. JavaScript being selenium’s strength was also its weakness. Browsers impose a very strict security model on any JavaScript that they execute in order to protect a user from malicious scripts. Examples of where this security model makes testing harder are when trying to upload a file (IE prevents JavaScript from changing the value of an Input file element) and when trying to navigate between domains (because of the single host origin policy problem). Selenium API has also grown over time and with that, it’s become harder to understand how to best use it. I personally found the API difficult to navigate.

To solve these problems, I said Hi to Selenium 2 also know as Webdriver! Webdriver takes a different approach to solve the same problem as Selenium. Rather than being a JavaScript application running within the browser, it uses whichever mechanism is most appropriate to control the browser. For Firefox, this means that WebDriver is implemented as an extension. For IE, WebDriver makes use of IE’s Automation controls. According to Selenium HQ:

The primary new feature is the integration of the WebDriver API. This addresses a number of limitations along with providing an alternative, and simpler, programming interface. The goal is to develop an object-oriented API that provides additional support for a larger number of browsers along with improved support for modern advanced web-app testing problems.

Let’s hope that is the case. I am starting to switch over from Selenium  RC to Webdriver. Along the way, I will be sharing my findings with you. The aim is to one day, change the beast (Automated Refunds Testing Framework) from Selenium RC to Webdriver. I will also be using Automated Refunds as my guinea pig while learning Webdriver. Watch this space!

Leave a Reply

Your email address will not be published.