# XPath Cheat Sheet: Syntax, Functions, and Examples

DevFeed: [XPath Cheat Sheet: Syntax, Functions, and Examples](<https://devfeed.tech/articles/xpath-cheat-sheet-syntax-functions-and-examples-50589.md>)

Original publisher: [Read original article](<https://testgrid.io/blog/xpath-cheat-sheet/>)

Author: Jayesh Karkar

Published: 2026-09-03T13:18:35Z

Content type: tutorial

Language: en

Sources: [TestGrid](<https://devfeed.tech/sources/testgrid-blog.md>)

Topics: [Software Testing](<https://devfeed.tech/topics/software-testing.md>), [Test automation](<https://devfeed.tech/topics/test-automation.md>), [Selenium](<https://devfeed.tech/topics/selenium.md>), [Document Object Model (DOM)](<https://devfeed.tech/topics/dom.md>), [selectors](<https://devfeed.tech/topics/selectors.md>), [XML](<https://devfeed.tech/topics/xml.md>), [HTML](<https://devfeed.tech/topics/html.md>)

Tags: [cheat-sheet](<https://devfeed.tech/tags/cheat-sheet.md>), [examples](<https://devfeed.tech/tags/examples.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [selenium](<https://devfeed.tech/tags/selenium.md>), [test-automation](<https://devfeed.tech/tags/test-automation.md>), [testing](<https://devfeed.tech/tags/testing.md>), [xpath](<https://devfeed.tech/tags/xpath.md>), [xpath-cheat-sheet](<https://devfeed.tech/tags/xpath-cheat-sheet.md>)

## AI overview

A practical XPath cheat sheet for web test automation. It explains XPath syntax, functions, predicates, axes, indexing, and locator patterns, including comparisons with CSS selectors and Selenium locator strategies.

## Source excerpt

When automated tests interact with web elements, they need locators that can reliably identify the intended element without depending on fragile selectors or XPath expressions. Why? Because even small changes to the page's DOM structure, attributes, or element hierarchy can cause the locator to stop working and fail the test. XPath gives you a flexible [...]