Thank you for all answers. I found solution to my problem. The last command was command which was linked with IFrame

WebElement editorFrame = driver.findElement(By.cssSelector("#sentmsgcomposeEditor_ifr"));
   driver.switchTo().frame(editorFrame);

   WebElement body1 = driver.findElement(By.tagName("body"));
   body1.sendKeys(Keys.CONTROL + "a"); 

So i was in IFrame actually because of it i couldn't find any element. I performed following command:

 driver.switchTo().defaultContent();

After that it is possible to find locators.

Answer from Bilow Yuriy on Stack Overflow
🌐
TutorialsPoint
tutorialspoint.com › unable-to-locate-an-element-using-xpath-error-in-selenium-java
Unable to locate an element using xpath error in selenium-java
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; public class XpathError{ public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe"); WebDriver driver = new ChromeDriver(); //launch URL driver.get("https://www.tutorialspoint.com/index.htm"); WebElement m = driver.findElement(By.xpath("//*[text()='Library']")); m.click(); //explicit wait condition - visibilityOfElementLocated w.until(ExpectedConditions.visibilityOfElementLocated (By.linkText("Subscribe to Premium"))); System.out.println("Page title: " + driver.getTitle()); driver.quit(); } }
Discussions

Can't get element by XPATH
You're using an absolute xpath, which is almost always a bad idea. This xpath might work at one point, but it's also very prone to failure with even the slightest change in the page's DOM structure. Try coming up with an xpath that more uniquely identifies the element instead of tracing it all the way back to the html tag. More on reddit.com
🌐 r/selenium
4
2
December 4, 2021
selenium - Webdriver Automation - Unable to find element using xpath - Stack Overflow
Environment: Eclipse - Java - Junit - firefox webdriver Screen shot url : https://www.dropbox.com/s/26fl2l1y1mkpxiz/Screenshot 2014-01-06 01.52.43.png I am trying to test a webpage but unable... More on stackoverflow.com
🌐 stackoverflow.com
Selenium Java unable to locate element using xpath - Stack Overflow
This does not work for me and gives ...sTextList(By) in the type utilities is not applicable for the arguments (List) 2021-05-04T10:28:23.553Z+00:00 ... Isn't that obvious ? the return type of getElementsTextList method is ArrayList, basically this list eleTextList. However I have provided you a generic solution to handle multiple web elements. I have edited my answer for xpath ... More on stackoverflow.com
🌐 stackoverflow.com
Selenium can't locate element by xpath - Software Quality Assurance & Testing Stack Exchange
I am using Selenium and attempting to locate an element (table cell in a web app) by xpath. However, I am getting a NoSuchElementException when running my test cases. I am positive that the xpath More on sqa.stackexchange.com
🌐 sqa.stackexchange.com
November 16, 2018
🌐
Quora
quora.com › How-do-you-handle-being-unable-to-locate-an-element-in-Selenium
How to handle being unable to locate an element in Selenium - Quora
Answer: Hello, 1. Check in the event that there is any language structure mistake in our xpath expression. 2. Add extra expected wait conditions for the element. 3. Utilize an option xpath expression.
🌐
Google Groups
groups.google.com › g › selenium-users › c › OMgZGydnn0I
Xpath Correct but still get no such element: Unable to locate element:
PASSED: openURL FAILED: loginToTours **org.openqa.selenium.NoSuchElementException**: **no such element: Unable to locate element: {"method":"xpath","selector":"//input[@name='userName']"}** *** Element info: {Using=xpath, value=//input[@name='userName']} package SeleniumPracticePackage; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWa
🌐
Reddit
reddit.com › r/selenium › can't get element by xpath
r/selenium on Reddit: Can't get element by XPATH
December 4, 2021 -

Hello guys,

I'm trying to interact with the interative menu of this page in order to automate several data downloads instead of making it by hand.

The thing is that when I copy an XPATH of a selector (for example when I try to get the XPATH of the "Commodities" menu), selenium says:

Message: no such element: Unable to locate element: {"method":"xpath","selector":"/html/body/div[9]/div[1]/div[3]/ul/li[6]"}

Does anyone know why I can't get the element?

Thank you all in advance!

EDIT WITH SOLUTION:

The problem was that items I want to find are inside an iframe. So I have to switch the context of the webdriver first. Code with the solution:

from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.get('https://www.dukascopy.com/swiss/english/marketwatch/historical/')

table = driver.find_element(By.XPATH, '/html/body/div/main/div[2]/div/div/div/p[3]/iframe')

driver.switch_to.frame(table)

driver.find_element(By.XPATH, '/html/body/div[9]/div[1]/div[3]/ul/li[13]').click()

🌐
Stack Overflow
stackoverflow.com › questions › 67382575 › selenium-java-unable-to-locate-element-using-xpath
Selenium Java unable to locate element using xpath - Stack Overflow
By machineUIList = By.xpath("//div[@class='thmbinnerdiv']"); Thread.sleep(5000); ArrayList<String> machineUITextList = objUtilities.getElementsTextList(machineUIList); Thread.sleep(5000); System.out.println(machineUITextList);
Find elsewhere
🌐
Edureka Community
edureka.co › home › community › categories › selenium › not able to find element with xpath
Not able to find element with Xpath | Edureka Community
July 4, 2018 - Selenium Webdriver Java - Eclipse java lang NoClassDefFoundError Oct 1, 2024 ... "Error: Unable to initialize main class Commands.Getcommands Caused by: java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriver" how to resolve this?
🌐
BrowserStack
browserstack.com › home › guide › find element by xpath in selenium in 2026
How to find element by XPath in Selenium [2026] | BrowserStack
December 19, 2025 - Many testers assume XPath in Selenium is easy—inspect an element, copy the XPath, and move on. I thought the same until a minor UI update broke half my tests in one run. Suddenly, every copied XPath failed, and I spent hours regenerating locators that kept breaking again.
🌐
Reddit
reddit.com › r/selenium › cannot find element by xpath although it is there.
r/selenium on Reddit: Cannot find element by XPATH although it is there.
June 3, 2023 -

Hey guys, new to the community and new to using Selenium. Can I please have some help? I am using Python and Selenium for navigating through a website. The website is turo.com; my goal is to login using my code.

So far, I am able to open the website, navigate to the "log in" button and click on it. After the login button is clicked, there is a modal that pops up with 2 input fields for email/user and password. I have the XPATH to the input fields but they are not working. I get the following error message:

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"html/body/div[1]/form/div[1]/input[@id="email"]"}

Please let me know how to debug this error. I have tried stackoverflow and other forums but no answer so far. Thank you!

EDIT: I have tried using '//input[@data-testid="email"]' as well.

🌐
GitHub
github.com › seleniumhq › selenium-google-code-issue-archive › issues › 5047
Unable to locate element: {"method":"xpath","selector":"//*[@id='usernameTextEdit']"} · Issue #5047 · SeleniumHQ/selenium-google-code-issue-archive
March 4, 2016 - ----------------------------------------------------------- public class Login { public static void main(String[] args) { WebDriver d1= new FirefoxDriver(); d1.navigate().to("http://inlv50795915s:8080/InfoViewApp"); d1.findElement(By.xpath("//*[@id='usernameTextEdit']")).sendKeys("administrator"); } } --------------------------------------------------------------- Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"xpath","selector":"//*[@id='usernameTextEdit']"} Command duration or timeout: 188 milliseconds For documentation on this erro
Author   lukeis
🌐
Reflect
reflect.run › articles › everything-you-need-to-know-about-nosuchelementexception-in-selenium
Everything you need to know about NoSuchElementException in Selenium | Reflect
July 29, 2022 - NoSuchElementException is one of ... element cannot be found. A NoSuchElementException occurs when the Selenium locator strategy defined is unable to find the desired HTML element in the web page....
🌐
Quora
quora.com › In-Selenium-WebDriver-after-the-launching-browser-I-am-getting-an-error-as-unable-to-locate-element-even-if-the-locator-is-correct-What-can-be-done-to-be-successful
In Selenium WebDriver, after the launching browser, I am getting an error as unable to locate element even if the locator is correct. What can be done to be successful? - Quora
Answer (1 of 10): Check the following things:- 1. Check whether you are trying to locate web element in the correct frame. If not switch the frame and then try to locate it. 2. Make sure you are using the correct by class methods for your locator.
🌐
Team Treehouse
teamtreehouse.com › community › i-got-unable-to-locate-element-error-2
I got Unable to locate element error (Example) | Treehouse Community
January 21, 2018 - //inviteeNameField: By.name("name") inviteeNameField : By.css("#registrar input[name=\"name\"]"), toggleNonRespondersVisibility : By.css(".main >div input"), removeButton : By.css("#invitedList li button + button"), //removeButtonForInvitee : By.css("#invitedList li button + button") //removeButtonForInvitee : By.xpath("//li/button[2]") }; function removeInvitee(){ driver.findElement(locator.removeButton) .click(); } function addInvitee(name){ driver.findElement(locator.inviteeNameField) .sendKeys(name); driver.findElement(locator.inviteForm).submit(); ... function toggleNonRespondersVisibility(){ driver.findElement(locator.toggleNonRespondersVisibility) .click(); } ... I came across the same problem and realized I wasn't using Selenium v3.