Migration from Selenium RC to WebDriver

Selenium Remote control got birth from the JavaScriptTestRunner that Jason huggins developed for automating their In-House Time -n- Expenses application.

Selenium RC had few limitations that created serious problems with the advancement of rich internet applications like Same Origin Policy file Uploads and few others..

Selenium RC is officially deprecated now with no further development but with a maintenance mode and its high time that we need to migrate to WebDriver.

Over these past years, we have spent many time in developing automated web tests with selenium RC and its not possible to migrate Selenium RC Scripts to WebDriver overnight, but a high amount of time and cost involves in migrating scripts to WebDriver.

If you are starting fresh, then it should be WebDriver.

Using WebDriverBackedSelenium make’s sense to easily migrate your test scripts from Selenium Rc to WebDriver.

Let’s see how we migrate from Selenium RC to WebDriver

Selenium RC code look like this

String strBaseUrl = "http://assertselenium.com/";
String strBrowserName = "*firefox"
String strPortNumber = "5555"
String strHost = "localhost"

selenium = new DefaultSelenium(strHost, strPortNumber , strBrowserName , strBaseUrl);
selenium.click("link=Contact Me");

//Can be many more steps involved...


You may use any WebDriver implementation, here we use Firefox Driver

String strBaseUrl = "http://assertselenium.com";

//Creating a WebDriver implementation
WebDriver driver = new FirefoxDriver();

//Selenium rc implementation
Selenium selenium = new DefaultSelenium(driver, strBaseurl);

//Performing actions with selenium
selenium.click("link=Contact Me");

//Can be many more steps
/* And get the underlying WebDriver implementation back. 
*This will refer to the same WebDriver instance as the "driver" variable above.
WebDriver driverInstance = ((WebDriverBackedSelenium) selenium).getUnderlyingWebDriver();

Using selenium.start() is not required because, we have already created the WebDriver session. At the end of the test we shall use the driver.quit() instead of selenium.stop().

WebDriver doesn’t support all browser’s as Selenium Rc used to support. In order to use that ability while still using the WebDriver you shall use the SeleneseCommandExecutor

It can be done using,

Capabilities dCaps = new DesiredCapabilities()
dCaps.setBrowserName("some new browser");
CommandExecutor executor = new SeleneseCommandExecutor("http:localhost:4444/", "http://www.google.com/", capabilities);
WebDriver driver = new RemoteWebDriver(executor, dCaps);

Hope that helps!!

2 Responses to “Migration from Selenium RC to WebDriver”
  1. Sebastian says:

    In our company we recently implemented RC for a client… but we are facing serious problem because of rich applications, for example we have spent entire weeks trying to capture entire screenshot and SnapsIE doesn’t work for us, our client has another requirement that involves MouseOver, it seems like RC also have problems executing that command… the reason for offering RC was because it was perfect for people that don’t have knowledge about code… so it was easy to use IDE for recording and RC for playback… However we need to move soon to Webdriver… :s

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: