Elements are not recognised in selenium

0 votes
Sometimes while running the code, elements are not recognized even though they are present. Can someone help me?

I am trying to search for a keyword in google and sometime after executing the code, I get an error saying no element found. Even though the search box is there.
Jan 4, 2019 in Selenium by Jino
• 5,670 points
948 views

1 answer to this question.

0 votes

Many a times the problem is that the web elements are not loaded when you execute the code. The best practice is to wait till you find the element and then you try doing operations on the web-element. Here is an example of how to do that:-

try using explicit wait :

WebDriverWait wait = new WebDriverWait(webDriver,60);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.name("q")));

This way selenium will wait till your searchbox will appear in the website.

Hope this helps.

answered Jan 4, 2019 by Dhruva

Related Questions In Selenium

0 votes
1 answer

Selenium ChromeDriver issue - Want to run it in background, but not as headless browser

This is a flaw with ChromeDriver. Tried ...READ MORE

answered Mar 26, 2018 in Selenium by nsv999
• 5,510 points
3,081 views
0 votes
1 answer

What are the differences between getText() and getAttribute() functions in Selenium WebDriver?

See, both are used to retrieve something ...READ MORE

answered Apr 5, 2018 in Selenium by nsv999
• 5,510 points
9,389 views
0 votes
1 answer

XPath for the elements with no ID or Name in Selenium Webdriver

Use like this or similar to this: //div[@id="top-level-menu-item-3"]/div[@class="filter-label"] //div[@id="top-level-menu1"] ...READ MORE

answered Apr 17, 2018 in Selenium by Meci Matt
• 9,460 points
2,608 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,510 points
3,095 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,890 points
2,346 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,890 points
2,493 views
+2 votes
4 answers

sendKeys() not working in Selenium Webdriver

this work for me you should update your ...READ MORE

answered Aug 27, 2019 in Selenium by Afif
21,320 views
0 votes
1 answer

What are the main disadvantages of using implicit wait in Selenium?

Hey Aaron, the main disadvantage of implicit ...READ MORE

answered May 31, 2019 in Selenium by Abha
• 27,930 points
998 views