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,520 points
70 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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,030 points
1,504 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,590 points
10,209 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,400 points
4,908 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,030 points
71 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
439 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
55 views
+4 votes
1 answer
0 votes
1 answer

How to use link as a locator to find element in selenium?

Hello @Jino, its amazing to explore ways ...READ MORE

answered Dec 21, 2018 in Selenium by Nabarupa
48 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.