In this article I will explain you how you can use your existing Selenium RC commands in Webdriver with some changes made to the code. This is more like Webdriver backward compatability with Selenium RC.
Here is a google search example that does a search for selenium wiki and validating the same on the google search results page.
package Htmltests;
import com.thoughtworks.selenium.Selenium;
import org.openqa.selenium.*;
import org.openqa.selenium.htmlunit.*;
import org.openqa.selenium.firefox.*;
import org.openqa.selenium.chrome.*;
import org.openqa.selenium.ie.*;
import org.junit.*;
import static org.junit.Assert.*;
@SuppressWarnings("unused")
public class SW {
public static void main(String[] args) throws InterruptedException { //update this
//public void setUp() { // remove the setUp
//driver = new FirefoxDriver();
// selenium = new WebDriverBackedSelenium(driver, "http://www.google.com/");
//}
WebDriver driver = new FirefoxDriver(); // add this
String baseUrl = "http://www.google.com.au"; // add this
// Create the Selenium implementation
Selenium selenium = new WebDriverBackedSelenium(driver, baseUrl); // add this
//public void tearDown() { // remove the tearDown
// driver.close();
//}
//public void testUntitled() { // remove this
selenium.open("");
selenium.type("q", "selenium wiki");
selenium.click("btnG");
Thread.sleep(5000);
try
{
assertTrue(selenium.isTextPresent("Selenium Wiki"));
System.out.println("Selenium Wiki is present on the google search results page");
}
catch (Exception e)
{
System.out.println("Selenium Wiki is present on the google search results page");
}
driver.close(); // add this to close the webdriver
//} // remove this
}
}
Here is the template that I have created for you removing all the commented sections.
package Htmltests;
import com.thoughtworks.selenium.Selenium;
import org.openqa.selenium.*;
import org.openqa.selenium.htmlunit.*;
import org.openqa.selenium.firefox.*;
import org.openqa.selenium.chrome.*;
import org.openqa.selenium.ie.*;
import org.junit.*;
import static org.junit.Assert.*;
@SuppressWarnings("unused")
public class SW {
public static void main(String[] args) throws InterruptedException {
WebDriver driver = new FirefoxDriver();
String baseUrl = "http://www.seleniumwiki.com"; // Change the url
// Create the Selenium implementation
Selenium selenium = new WebDriverBackedSelenium(driver, baseUrl);
//add your selenium RC test script code here
driver.close(); // add this to close the webdriver
}
}

Hi,
I’m getting error in the following code line:
Selenium selenium = new WebDriverBackedSelenium(driver, baseUrl); // add this
And error is: “WebDriverBackedSelenium cannot be resolved to a type”
What is the solution, can you explain?
Can you make sure you have imported – import com.thoughtworks.selenium.Selenium;
This will only work in Java. Thoughtworks/Google has not yet found a way to work it on C# and other languages. If you still have problems send me the code.
[...] Selenium Tips Here are top Selenium Tips: Using Selenium RC commands in Webdriver Selenium 2 Selenium Data Driven Testing with C# Selenium RC with Visual Studio 2010 and NUnit Create a Java [...]