WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com.hk/");
//PageObjects design pattern
GoogleSearchPage googlesearchpage =
PageFactory.initElements(driver, GoogleSearchPage.class);
String baseUrl = driver.getCurrentUrl();
//Change into Selenium instance
Selenium selenium = new WebDriverBackedSelenium(driver, baseUrl);
//Using selenium method
selenium.type("q", "Gmail");
selenium.click("btnG");
//using PageObjects and driver
googlesearchpage.clearsearchtext(driver);
googlesearchpage.searchfor(driver, "joychester");
//change back to Webdriver instance
WebDriver driverInstance =
((WebDriverBackedSelenium)selenium).getUnderlyingWebDriver();
googlesearchpage.clearsearchtext(driver);
googlesearchpage.searchfor(driverInstance, "Gmail");
//close browser and stop selenium
driverInstance.close();
selenium.stop();
Tuesday, July 13, 2010
Emulating selenium APIs within WebDriver
Emulating selenium APIs within WebDriver which allows for the WebDriver and Selenium APIs to live side-by-side, a simple sample FYI:
Subscribe to:
Post Comments (Atom)
In Emulating selenium api's with webdriver, Does this emulation works if i export testcases in c#.net
ReplyDeleteHi, geetha,
ReplyDeleteI am not a C#.net user, so can not answer your question here :)