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(); } }
🌐
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:
FileInputStream urlFile = new FileInputStream("C:\\Users\\Ashish\\Documents\\Selenium\\SeleniumPracticeSite\\src\\URL.properties"); ... myDynamicElement.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//input[@name='userName']"))); ... <tr> <td align="right"><font face="Arial, Helvetica, sans-serif" size="2">User Name: </font></td> <td width="112"> <input type="text" name="userName" size="10"> </td> ... http://stackoverflow.com/questions/39561188/xpath-is-correct-still-get-no-such-element-unable-to-locate-element?noredirect=1#comment66434922_39561188
🌐
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()

🌐
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.

🌐
Stack Overflow
stackoverflow.com › questions › 23927510 › unable-to-locate-an-element-with-the-xpath-expression
java - Unable to locate an element with the xpath expression - Stack Overflow
... I would suggest you to identify the element which is above/below/next to the element which you are looking for with text and using xpath methods like following-sibling/preceding methods and identify the element..
Find elsewhere
🌐
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.
🌐
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....
🌐
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?
🌐
Stack Overflow
stackoverflow.com › questions › 67382575 › selenium-java-unable-to-locate-element-using-xpath
Selenium Java unable to locate element using xpath - Stack Overflow
Connect and share knowledge within a single location that is structured and easy to search. Learn more about Teams ... Below is the code where selenium is unable to find the element. By machineUIList = By.xpath("//div[@class='thmbinnerdiv']"); Thread.sleep(5000); ArrayList<String> machineUITextList = objUtilities.getElementsTextList(machineUIList); Thread.sleep(5000); System.out.println(machineUITextList);
🌐
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.
🌐
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
🌐
GitHub
github.com › SeleniumHQ › selenium › issues › 14849
[🐛 Bug]: Cant find element using Xpath · Issue #14849 · SeleniumHQ/selenium
December 4, 2024 - OpenQA.Selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//h1[@contenteditable='true' and @aria-label='Add title']"} (Session info: chrome=131.0.6778.86); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception at OpenQA.Selenium.WebDriver.UnpackAndThrowOnError(Response errorResponse, String commandToExecute) at OpenQA.Selenium.WebDriver.ExecuteAsync(String driverCommandToExecute, Dictionary`2 parameters) at OpenQA.Selenium.WebDriver.Execute(String dr
Author   anugrahjayaaaa