XPath & CSS Selector Generator for Playwright, Selenium & Cypress
Paste an HTML snippet, click any element, and get robust, validated locators — plus a full Page Object class and a CSV export of every interactive element. Faster than SelectorsHub, works without a browser extension, and never sends your HTML to a server.
1. Paste HTML
2. Click an element
Loading…
3. Generated locators
Each locator is validated against your DOM. Prefer best over fragile.
Runs entirely in your browser
Uses the native DOMParser API — no upload, no signup, no tracking. Safe for pasting internal app HTML you couldn't send to a cloud selector tool.
Live selector validation
Every generated XPath and CSS selector is executed against your DOM so you know exactly how many elements it matches before you commit it to a test.
Framework-native output
Playwright getByRole / getByTestId, Selenium By.xpath, Cypress cy.get(), plus full Page Object classes for Playwright TypeScript, Selenium Java and Cypress JavaScript.
How to generate XPath and CSS selectors in 4 steps
- 1
Paste your HTML snippet
Copy the HTML for the section you're automating from Chrome DevTools (right-click element → Copy → Copy outerHTML) and paste it into the tool.
- 2
Click the target element
The interactive element tree shows every parsed node. Click the input, button, link, or container you want a locator for.
- 3
Pick the best-tagged locator
The tool ranks each locator as best / good / fragile and shows a live match count. Prefer data-testid, getByRole with a name, or a stable id.
- 4
Copy or export
Copy a single locator, generate a full Page Object class for your framework, or bulk-export all interactive elements as CSV.
Locator strategy: which selector should you use?
The most common cause of flaky end-to-end tests is a fragile locator. Use this ranking when you pick from the generated list:
| Priority | Strategy | Why | Playwright |
|---|---|---|---|
| 1 | data-testid | Added by devs for tests — survives design refactors. | getByTestId() |
| 2 | ARIA role + accessible name | Enforces accessibility and matches user intent. | getByRole() |
| 3 | Label / placeholder text | Stable if UX doesn't rewrite copy. | getByLabel() / getByPlaceholder() |
| 4 | Stable id | Fine when ids aren't hashed by build tools. | locator('#id') |
| 5 | CSS attribute selector | Good for name/type combos on inputs. | locator('input[name=...]') |
| 6 | XPath contains-text | Use when nothing else is stable. | locator('xpath=...') |
| 7 | Absolute XPath | Last resort — breaks on any DOM shuffle. | avoid |
How this compares to SelectorsHub, ChroPath & Chrome DevTools
| Feature | This tool | SelectorsHub | ChroPath | DevTools |
|---|---|---|---|---|
| No install (any OS/Chromebook) | Yes | No | No | No |
| Playwright getByRole / getByTestId output | Yes | Partial | No | No |
| Bulk CSV export of all elements | Yes | No | No | No |
| Full Page Object class generator | Yes | No | No | No |
| Works on pasted HTML (offline app) | Yes | No | No | No |
| 100% client-side (privacy) | Yes | Extension | Extension | Local |
Level up your automation
Robust locators are the #1 predictor of a stable automation suite. Deepen your skills with these guides:
Frequently asked questions
1.Is this XPath and CSS selector generator really free?
2.Which locator should I use in Playwright?
3.Does the selector generator support Selenium, Cypress, and WebdriverIO?
4.Why is my absolute XPath marked 'fragile'?
5.Can I paste an entire page's HTML?
6.Does it work with iframes and Shadow DOM?
7.What makes this different from SelectorsHub or ChroPath?
8.Does it generate Playwright Page Object Model classes?
Found this useful? Share it with your QA team — every share helps us keep this tool free and ad-free.