XPath Playground
Test your XPath expressions against sample DOMs. Click elements to generate suggestions, or type your own expressions.
Quick Tips
- • Use
//for relative paths (recommended) - • Prefer
@data-testidfor stability - • Use
contains()for partial matching - • Press Ctrl+Enter to evaluate
Common Patterns
- •
//*[@id='value'] - •
//button[text()='Submit'] - •
//input[@type='email'] - •
//*[contains(@class,'btn')]
Robustness Guide
- Stable - data-testid, aria-*, id
- Medium - text, class, href
- Fragile - position, absolute path