Thursday, January 9, 2014

Transformation from Manual tester to a Selenium WebDriver Automation specialist

TasksHuman Interaction (Manual Tester)WebDriver Commands
Invoke BrowserTester manually opens the browser Firefox, IE, chrome or Safari
WebDriver driver=new FirefoxDriver();
WebDriver driver=new SafariDriver();
WebDriver driver=new chromeDriver();
WebDriver driver=new InternetExplorerDriver();
This is actually a WebDriver object instantiation and
this will invoke the browser according to different
WebDriver implementation.
Load URL of ApplicationTester manually type’s in the URL http://www.google.com
driver.get("http://www.google.com");
Loads the given url into the browser
ClickTester clicks on the Search field in the Google home page
driver.findElement(By.cssSelector("#gbqfq")).click();
driver.findElement(By.cssSelector("#gbqfq")).clear();
Click actually comes with clear command in WebDriver.
Clear command will simply clear the input field. Basically
to avoid the auto-form fill.
TypeTester types the words manually
driver.findElement(By.cssSelector("#gbqfq")).sendKeys("test");
Types “test” into the input element identified by css selector.
Select from Drop-downTester clicks on the Drop-down field and selects the required option
Select select = new Select(driver.findElement(By.tagName
("select")));
select.selectByVisibleText("Apple");
Selects the text
displayed as “Apple” in the select combo box which
is identified by tag name “select”
Moving between WindowsTester will simply click on the window or will do a Alt+tab combination to toggle between windows
driver.switchTo().window("windowName");
driver.switchTo().frame("frameName");
We can switch between frames or iframes using above command.
Alert HandlingTester knows that Alert will be pop-up and then asserts it.
driver.findElement(By.xpath (“<Xpath>”)).click();
Alert alert = driver.switchTo().alert();
alert.accept();

No comments:

Post a Comment