Wednesday, 13 May 2015

WAP to enter "wipro" in google search editbox and capture all the auto suggested list and display it on console.

package Assignments;

import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

public class CapturingAllAutoSuggested {

public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.get("http://google.com");

driver.findElement(By.id("lst-ib")).sendKeys("wipro");

List<WebElement> lst = driver.findElements(By.xpath("//div[div[div[div[div[input[@id='lst-ib']]]]]]/following-sibling::div/div/div/div/ul/li"));

for(int i=0;i<lst.size();i++)
{
String s = lst.get(i).getText();
System.out.println(s);
}


}

}

No comments:

Post a Comment