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 21, 2018 in Selenium by Jino
• 5,810 points
5,267 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 21, 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,500 points
19,832 views
+1 vote
5 answers

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

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

answered Apr 21, 2018 in Selenium by king_kenny
• 3,710 points
82,260 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,500 points
12,767 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

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

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
8,631 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,910 points
6,705 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 3, 2020 in Selenium by Sri
• 3,190 points
7,570 views
+4 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP