Google auto-suggestion element is not finding | Selenium Forum
S
Sand vazhapilly Posted on 01/11/2020

I am trying to get the 4th auto-suggestion from the google search field. Running the program returns 'no element found error'. Can you please help.

Note: I can find my xpath  element when inputting in the search field.

 

Here is the code

driver.manage().window().maximize();

driver.get("http://www.google.com");

driver.findElement(By.name("q")).sendKeys("coro");

System.out.println(driver.findElement(By.xpath("//form[@id=\"tsf\"]/div[2]/div[1]/div[3]/div[2]/ul/li[4]/div/div[2]/div/span/b")).getText());


A
Ashish Replied on 04/11/2020

Before the list loads with elements, you have to give some wait.

So that the complete list of elements is loaded and then try to read

You can use explicit wait or thread.sleep to inroduce wait