Sunday, February 3, 2013

Selenium - Automation Testing


Selenium WebDriver is used to automate browsers. We can code in Java using Eclipse IDE to automate testing web applications in various browsers.

package org.openqa.selenium.example;
 import org.openqa.selenium.By; 
import org.openqa.selenium.WebDriver; 
import org.openqa.selenium.WebElement; 
import org.openqa.selenium.htmlunit.HtmlUnitDriver;

 
public class Example  {
   
public static void main(String[] args) {
       
 WebDriver driver = new HtmlUnitDriver();
       
 driver.get(http://www.google.com); 
        WebElement element = driver.findElement(By.name("q"));        
element.sendKeys("Selenium!");        
 element.submit();        
System.out.println("Page title is: " + driver.getTitle());
   
} 
}

We can use Qualitia tool to make this automation task easier. It is an application created in java to help with the testing purpose.