Selenium WebDriver Java Framework Course Limited Time Offer for $20

Selenium WebDriver Java Framework Course Limited Time Offer for $20

 

Print

How to run Selenium 1.0 tests in webdriver

We need to use WebDriver-Backed Selenium-RC. 

 

The Java version of WebDriver provides an implementation of the Selenium-RC API. These means that you can use the underlying WebDriver technology using the Selenium-RC API. This is primarily provided for backwards compatibility. It allows those who have existing test suites using the Selenium-RC API to use WebDriver under the covers. It’s provided to help ease the migration path to Selenium-WebDriver. Also, this allows one to use both APIs, side-by-side, in the same test code.

// You may use any WebDriver implementation. Firefox is used here as an example
       WebDriver driver = new FirefoxDriver();

       // A "base url", used by selenium to resolve relative URLs
        String baseUrl = "http://seleniummaster.com";

       // Create the Selenium implementation
       Selenium selenium = new WebDriverBackedSelenium(driver, baseUrl);

       // Perform actions with selenium

       selenium.open("http://seleniummaster.com");
       selenium.type("name=username""xxxx");
       selenium.click("name=login");
       // Get the underlying WebDriver implementation back. This will refer to the
       // same WebDriver instance as the "driver" variable above.
       WebDriver driverInstance = ((WebDriverBackedSeleniumselenium).getWrappedDriver();
       //Finally, close the browser. Call stop on the WebDriverBackedSelenium instance
       //instead of calling driver.quit(). Otherwise, the JVM will continue running after
       //the browser has been closed.
       selenium.stop();