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 in Selenium by Jino
• 5,560 points
151 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 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,110 points
1,208 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,110 points
5,938 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,420 points
1,460 views
0 votes
1 answer

Not able to open a new URL in a new tab in Selenium

There is a bug in ChromeDriver that ...READ MORE

answered May 21, 2018 in Selenium by Meci Matt
• 9,420 points
9,081 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,110 points
955 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,130 points
1,124 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,130 points
861 views
+2 votes
4 answers

sendKeys() not working in Selenium Webdriver

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

answered Aug 27 in Selenium by Afif
13,921 views
0 votes
1 answer