| Syntax | Type | Description | Example |
|---|---|---|---|
/ (Single Slash) | Absolute XPath | Selects from root node only. Every intermediate node must be specified. | html/body/div/input |
// (Double Slash) | Relative XPath | Selects matching nodes anywhere in the document. | //input[@id=''user''] |
Single Slash Example:
XPATH
html/body/div[1]/form/input
Must start from html root — very rigid.
Double Slash Example:
XPATH
//form/input
Finds any form > input combo anywhere in the DOM.
Combined usage:
XPATH
//div[@id=''login'']//input[@type=''text'']
Start relative, then go deeper.
Key Rule: Always prefer
//in automation — makes tests resilient to DOM changes.
