Getting error saying element not found in selenium

0 votes

I am working on a webpage.

1.The problem is that when I click on a link it opens in another tab.

2. When I try to locate an element I get an error:

no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id='container']/div/div[1]/div[2]/div/div[1]/div[1]/div[2]/div/ul/li[1]/button"}
  (Session info: chrome=71.0.3578.98

Can someone help? I am pretty sure that I have used the correct Xpath.

Dec 20, 2018 in Selenium by Jino
• 5,770 points
2,687 views

1 answer to this question.

0 votes

Hey @Jino, The things I figured out with your problem is that,

1. when the second tab opens selenium webdriver is still working on the first one and is not aware of the second tab.

2. You are using the wrong locator to do the task.

Either you close the first tab so that webdriver works on the second tab or force the link to open in same tab.

For closing the first tab you can see the set of statement I used here:

I used an ArrayList and stored both tabs then navigated and closed the first one.

https://www.edureka.co/community/33842/how-do-i-close-the-first-tab-in-chrome-using-selenium-in-java

answered Dec 20, 2018 by Shuvodip

Related Questions In Selenium

–1 vote
1 answer

Selenium XPath error:- Element not found

The reason for Element not found exception ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,520 points
9,683 views
+1 vote
3 answers

Getting this error: “Element is not clickable at point”

There are 3 possible solutions for this: 1. ...READ MORE

answered Apr 20, 2018 in Selenium by king_kenny
• 3,710 points
58,432 views
0 votes
2 answers

Check that the element is clickable or not in Selenium WebDriver

Hi , you want to know only is ...READ MORE

answered Aug 31 in Selenium by Sri
• 2,970 points
21,026 views
0 votes
2 answers

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,520 points
3,806 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31 in Selenium by Sri
• 2,970 points
4,787 views
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,758 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 2 in Selenium by Sri
• 2,970 points
3,122 views
+4 votes
1 answer