public class Auto_Suggestions {
WebDriver driver;
@BeforeTest
public void start(){
driver = new FirefoxDriver();
}
@Test
public void SearchSuggestion() {
driver.get("http://google.com");
driver.findElement(By.id("gbqfq")).sendKeys("v2tech");
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
WebElement table = driver.findElement(By.className("gssb_m"));
List<WebElement> rows = table.findElements(By.tagName("tr"));
Iterator<WebElement> i = rows.iterator();
System.out.println("-----google auto suggestions are:---------");
while(i.hasNext()) {
WebElement row = i.next();
List<WebElement> columns = row.findElements(By.tagName("td"));
Iterator<WebElement> j = columns.iterator();
while(j.hasNext()) {
WebElement column = j.next();
System.out.println(column.getText());
}
System.out.println("");
System.out.println("google auto suggestions are:");
}
}
}