There was an error in this gadget

Technical Project Lead @ Huawei Technologies

My photo
Bangalore/Hyderabad, Karnataka/Andhra Pradesh, India
Have an overall 10 + yrs of experience Currently working as an Senior Architect.Expertise in design,implementation of Automation frameworks for Opensource automation tools like Selenium,Jmeter, Webdriver,Appium, Robotium Expertise in integrating Test & ALM Management tools like Rally,Qmetry,JIRA-Zephyr with Automation frameworks Expertise in design and developmenet Mobile Automation frameworks for tools like Appium, Robotium Remote Control,Cucumber BDD


Saturday, August 10, 2013

How to verify Google Search List Options using Selenium RC/ Webdriver

Below is the snippet for list the google search list options using both Selenium RC and web driver

package selenium;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverBackedSelenium;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import com.thoughtworks.selenium.Selenium;

public class GoogleTests {
    static WebDriver driver;
    public static void main(String[] args) throws InterruptedException {
        driver = new FirefoxDriver();
        driver.findElement(By.xpath("//input[@type='text']")).sendKeys("Selenium webdriver");
         // Selenium Code to print all the options from the dropdown suggestionlist
        Selenium selenium = new WebDriverBackedSelenium(driver,
        System.out.println("Below list is printed by Selenium RC");
        int listCount = selenium.getXpathCount(
        for (int i = 1; i < listCount; i++) {
            String listValues = selenium
                    .getText("//table[@class='gssb_m']/tbody/tr[" + i
                            + "]/td[1]/div/table/tbody/tr[1]/td[1]/span");
        // Webdriver Code to print all the options from the dropdown suggestion list
        System.out.println("Below list is printed by Webdriver");
        List<WebElement> options = driver.findElements(By
        for (WebElement webElement : options) {
        // driver