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,560 points
265 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

0 votes
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,070 points
2,545 views
+1 vote
2 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,610 points
17,464 views
0 votes
1 answer

Check that the element is clickable or not in Selenium WebDriver

Use Selenium Waits: WebDriverWait ...READ MORE

answered Jun 12, 2018 in Selenium by Meci Matt
• 9,420 points
7,705 views
0 votes
1 answer
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,070 points
443 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
791 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
433 views
0 votes
1 answer
+4 votes
1 answer