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,550 points
44 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,050 points
773 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,050 points
4,350 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,400 points
995 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,400 points
5,936 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,050 points
281 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
644 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
271 views
+1 vote
3 answers

sendKeys() not working in Selenium Webdriver

driver.findElement(By.xpath("//label[text()='User Name:']/following::div/input")).sendKeys("UserName",Keys.TAB); By using a comma you can ...READ MORE

answered Feb 7 in Selenium by Priyaj
• 56,160 points
10,681 views
0 votes
1 answer