Skip to content
Tools

XPath Tester

Evaluate XPath expressions against your own HTML and see the matches.

Local
Matches

What this tool does

This tool evaluates an XPath expression against the HTML you provide and lists what it matches: elements, attributes or text nodes. Expressions that return a number, string or boolean, such as count(//li), show their value instead. It helps you build and check an XPath locator before you use it in a test.

How it stays safe

Your HTML is parsed into an inert document and queried with the browser XPath engine. Scripts never run, no external resources load, and nothing is uploaded. You can paste markup from a real page and only its structure is used.

When XPath earns its place

CSS selectors are shorter and usually the better default. Reach for XPath when you need something CSS cannot express: matching on an element's visible text, walking back up to a parent or ancestor, or selecting by position in document order. XPath is widely used with Selenium and Robot Framework, where it is a first-class locator.

Handy patterns

  • //button[normalize-space()='Add to cart'] match by exact visible text.
  • //label[text()='Email']/following-sibling::input find a field by its label.
  • //li[contains(class="",'product')] match part of a class list.
  • //a[@href]/ancestor::li walk up to an ancestor.
  • count(//li[@data-testid]) count matching elements.

Prefer text and attribute conditions over absolute paths like /html/body/div[2]/ul/li[3], which break as soon as the page changes.

Frequently asked questions

Is my HTML uploaded or rendered?
No. It is parsed into an inert document and queried with the browser XPath engine. Scripts never run, no resources load, and nothing is uploaded.
Can it return counts or text?
Yes. Expressions that return a number, string or boolean, such as count(//li), show their value, and text() and attribute selections are listed as matches.

Learning resources

Testsmith also runs hands-on courses and a free practice app for the skills behind this tool.

Feedback welcome

Found a bug in this tool, or want it to do something it does not? Tell us and we will take a look.