#1 India's Top IT Training Institute

×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
🎯 FREE · XPATH & CSS

XPath Tester: Check Your Selenium Locators Before You Run Tests

Paste HTML, type an XPath or CSS selector and see exactly what it matches.

  • 🔍 Match count and preview
  • 🔁 Updates as you type
  • ☕ Java and Python code

How to use the XPath Tester (Selenium)

  1. 1. Paste HTMLCopy outerHTML or page source from DevTools and paste it.
  2. 2. Type a locatorChoose XPath or CSS and write your expression.
  3. 3. Read the matchesSee the count, the matched elements and Selenium code to copy.

How the tester works

Your HTML is parsed with the browser's own DOMParser, which builds a document without running any scripts in it. XPath expressions are evaluated with the built-in document.evaluate, and CSS selectors with querySelectorAll, the same engines browsers use for Selenium's locators.

Example: the default login form has two inputs. The XPath //input[@type='password'] returns 1 match, so it is unique and safe to use. //input returns 2 matches, which would make findElement pick the first one silently. Functions that return a value, such as count(//input), show the value instead of elements.

Writing locators that do not break

  • Prefer relative XPath starting with //. Absolute paths like /html/body/div[2]/form break with any layout change.
  • Use stable attributes: id, name, data-testid, aria-label.
  • Match text carefully: normalize-space() ignores extra spaces that text() does not.
  • Use axes like following-sibling to find an input next to its label.
  • Check uniqueness on the full page, not just a snippet.

Pasted source is a snapshot. Content added by JavaScript after load only appears if you copy the HTML from the Elements panel after the page has rendered. In Chrome DevTools you can also run $x("//xpath") in the console. Generate locators automatically with the Selenium locator generator, and keep the locators cheat sheet open while you write.

Frequently asked questions

Does it support XPath 2.0 functions?

No. Browsers, and Selenium in the browser, support XPath 1.0, so functions like matches() or lower-case() are not available.

Is my HTML uploaded?

No. It is parsed and searched entirely in your browser.

Is the XPath Tester (Selenium) free?

Yes, the XPath Tester (Selenium) is free. The first time you test your first locator, you are asked for your name and WhatsApp number once. After that, this and every other Uncodemy tool opens straight away without the form.

More free tools

See all free tools