If you are using Google Chrome, right click on the button, and select Inspect in the popup. The html will open in a developer tools frame. Right click on the element in the developer tools frame, hover over copy, select copy xpath.

Here is the XPath to the form on the URL.

//*[@id="main-frame"]/div[1]/div[2]/div/div[1]/div[1]/form/regform-steps/ng-transclude/regform-step[1]/ng-form/ng-transclude/regform-button/button

    WebDriver driver = new ChromeDriver();
    driver.get("https://uk.match.com/unlogged/landing/2016/06/02/hpv-belowthefold-3steps-geo-psc-bowling?klid=6740");
    //fill in fields
    WebElement element = driver.findElement(By.xpath("//*[@id=\"main-frame\"]/div[1]/div[2]/div/div[1]/div[1]/form/regform-steps/ng-transclude/regform-step[1]/ng-form/ng-transclude/regform-button/button"));
    element.click();
Answer from ProgrammersBlock on Stack Overflow
๐ŸŒ
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 - Note: One can also locate the same element using the name attribute, as it has a locator value for the name tag as well. Using the name locator, the XPath is: ... Now letโ€™s try automating this using Selenium. Here is the Java program written in Eclipse for the same:
Discussions

Is there a way to get element by XPath using JavaScript in Selenium WebDriver? - Stack Overflow
But Selenium does not find everything that works with $x(""). 2020-12-01T07:39:51.75Z+00:00 ... $x wont work within script, it for console only. The accepted answer works within scripts running in browser context. 2021-06-10T16:06:49.633Z+00:00 ... To identify a WebElement using xpath and javascript ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
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
September 5, 2021
Find an element by text and get xpath - selenium webdriver junit - Stack Overflow
I have a table with 9 rows and 6 columns in my webpage. I want to search for a text "MakeGoodDisabled-Programwise_09_44_38_461(n)" and get the xpath of the cell. I have used the following but it fa... More on stackoverflow.com
๐ŸŒ stackoverflow.com
select - JAVA - How to use xpath in selenium - Stack Overflow
d.findElement(By.xpath("/selec...ption[text()='Auto']")).click(); d.findElement(By.xpath("//select[@id=category]/option[Auto]")).click(); ... Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"xpath","selector":"/se... More on stackoverflow.com
๐ŸŒ stackoverflow.com
People also ask

What is XPath?
XPath is XSLT standard element. It can be used to navigate elements in XML or HTML DOM contents.
๐ŸŒ
testsigma.com
testsigma.com โ€บ testsigma home โ€บ blog โ€บ find element by xpath: a complete guide
Find Element by XPath: A Complete Guide
How to find the XPath by Text?
The XPath can also be constructed to find text in the DOM element. In such cases, you need to use the text() functions in the XPath.Example://ul/li[text()='banana'].
๐ŸŒ
testsigma.com
testsigma.com โ€บ testsigma home โ€บ blog โ€บ find element by xpath: a complete guide
Find Element by XPath: A Complete Guide
How to find the XPath Value?
Any modern browserโ€™s developer tools can help to find the XPath value; there are third-party plugins that can help you to find the XPath easily. However, the browser dev tools can help you in most of the scenarios.
๐ŸŒ
testsigma.com
testsigma.com โ€บ testsigma home โ€บ blog โ€บ find element by xpath: a complete guide
Find Element by XPath: A Complete Guide
๐ŸŒ
Testsigma
testsigma.com โ€บ testsigma home โ€บ blog โ€บ find element by xpath: a complete guide
Find Element by XPath: A Complete Guide
July 31, 2025 - FindElements: A method in selenium, requires the LocatorStrategy as parameters. Returns the List containing the Web elements. ... Letโ€™s consider we have a list of footer links, and we wanted to fetch all the links at once and get the text. Then we can construct find elements by XPath like below,
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ software testing โ€บ best-way-to-get-element-by-xpath-using-javascript-in-selenium-webdriver
Best way to get element by XPath using JavaScript in Selenium WebDriver? - GeeksforGeeks
July 23, 2025 - Below code may be used to get the value for the id property of the search box element on the Google homepage: WebElement searchBox = driver.findElement(By.xpath("//input[@type=\"text\"]")); ... XPath is a useful tool for precisely and flexibly ...
๐ŸŒ
ScrapingBee
scrapingbee.com โ€บ webscraping-questions โ€บ selenium โ€บ how-to-find-elements-by-xpath-selenium
How to find elements by XPath in Selenium? | ScrapingBee
You can find elements by XPath selectors in Selenium by utilizing the find_element and find_elements methods and the By.XPATH argument. find_element returns the first occurence of the XPath selector being used, while find_elements returns all ...
๐ŸŒ
Selenium
selenium.dev โ€บ documentation โ€บ webdriver โ€บ elements โ€บ finders
Finding web elements | Selenium
September 6, 2025 - from selenium import webdriver from selenium.webdriver.common.by import By driver = webdriver.Chrome() driver.get("https://www.example.com") ##get elements from parent element using TAG_NAME # Get element with tag name 'div' element = driver.find_element(By.TAG_NAME, 'div') # Get all the elements available with tag name 'p' elements = element.find_elements(By.TAG_NAME, 'p') for e in elements: print(e.text) ##get elements from parent element using XPATH ##NOTE: in order to utilize XPATH from current element, you must add "." to beginning of path # Get first element of tag 'ul' element = driver.find_element(By.XPATH, '//ul') # get children of tag 'ul' with tag 'li' elements = element.find_elements(By.XPATH, './/li') for e in elements: print(e.text)
Find elsewhere
๐ŸŒ
Testim
testim.io โ€บ blog โ€บ find-element-by-xpath-selenium
How to Find an Element by XPath in Selenium - Testim Blog
October 14, 2022 - The most basic syntax for writing XPath in Selenium is as follows: ... Itโ€™s also possible to use the Contains() method in order to find a list of the elements that match the search predicate. This is particularly useful regarding elements whose values can change dynamically.
๐ŸŒ
Headspin
headspin.io โ€บ home โ€บ blogs โ€บ how to use xpath in selenium - a complete guide for beginners
XPath in Selenium - Definition, Examples and How to Use
July 26, 2023 - XPath locators in Selenium WebDriver are used to identify elements on a web page. These locators allow complex and flexible navigation of the web page's Document Object Model (DOM).
๐ŸŒ
Fishtank
getfishtank.com โ€บ insights โ€บ findelement-and-findelements-by-xpath-in-selenium
FindElement And FindElements By XPath In Selenium Automation Testing | Fishtank
FindElements in Selenium command takes in By object as the parameter and returns a list of web elements. It returns an empty list if there are no elements found using the given locator strategy and locator value.
๐ŸŒ
Bright Data
brightdata.com โ€บ faqs โ€บ selenium โ€บ find-elements-by-xpath
How to Find Elements by XPath in Selenium?
July 10, 2024 - In the above example, the find_element method uses XPath to locate elements on the webpage. The first XPath expression //tagname[@attribute='value'] finds a tag with a specific attribute value.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ find-element-and-findelements-by-xpath-in-selenium
Find Element and FindElements by XPath in Selenium
List<WebElement> n = driver.findElements(By.xpath("//ul[@class=' toc reading']/li")); WebElement m =driver.findElement(By.xpath("//ul[@class=' toc reading']/li[1]")); import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import java.util.concurrent.TimeUnit; import java.util.List; public class XpathFindElment{ public static void main(String[] args) { System.setProperty("webdriver.gecko.driver", "C:\Users\ghs6kor\Desktop\Java\geckodriver.exe"); WebDriver driver = new FirefoxDriver(); //implic
๐ŸŒ
Scientech Easy
scientecheasy.com โ€บ home โ€บ blog โ€บ find element by xpath in selenium
Find Element by XPath in Selenium - Scientech Easy
August 18, 2025 - How to instantiate WebDriver object to launch web browser, find element by XPath in Selenium with example, By class in Selenium, findElement
๐ŸŒ
The Test Tribe
thetesttribe.com โ€บ home โ€บ knowledge center โ€บ using xpath in selenium-java setup to find an element
Using Xpath in Selenium-Java Setup to Find an Element
February 25, 2025 - When we are getting similar types ... buttons; here, we need to use the index to identify them uniquely. Enclose the XPath in ( ) and forward by index in [ ]...
๐ŸŒ
TestGrid
testgrid.io โ€บ programming โ€บ what is xpath in selenium and how to find in chrome
How to Find XPath In Chrome For Selenium? | TestGrid
December 9, 2025 - You can also find elements with static attribute values. Text() Function in XPath: The XPath text() function is a Selenium web driver built-in function used to locate elements based on the text of a web element.
๐ŸŒ
Reddit
reddit.com โ€บ r/selenium โ€บ can't get element by xpath
r/selenium on Reddit: Can't get element by XPATH
September 5, 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()

๐ŸŒ
Selenium
selenium.dev โ€บ documentation โ€บ webdriver โ€บ elements โ€บ locators
Locator strategies | Selenium
February 16, 2026 - import pytest from selenium import webdriver from selenium.webdriver.common.by import By def test_class_name(): driver = webdriver.Chrome() driver.get("https://www.selenium.dev/selenium/web/locators_tests/locators.html") element = driver.find_element(By.CLASS_NAME, "information") assert element is not None assert element.tag_name == "input" driver.quit() def test_css_selector(driver): driver = webdriver.Chrome() driver.get("https://www.selenium.dev/selenium/web/locators_tests/locators.html") element = driver.find_element(By.CSS_SELECTOR, "#fname") assert element is not None assert element.get_
๐ŸŒ
Sauce Labs
saucelabs.com โ€บ home โ€บ blog โ€บ getting started with xpath in selenium
How To Use XPath In Selenium Tutorial With Examples | Sauce Labs
June 1, 2023 - The following is an example of the syntax for finding an element in XPath: ... There are two ways to locate an element in XPath: Absolute XPath and Relative XPath. The paths are defined by their XPath node, either the point where the path initiates ...