Skip to content
Black November: every course and Teams plan at the lowest price of the year with code BLACKFRIDAY, through November 30. Shop the deal

XPath: Locate Elements Using XPath

€19.00 28 Lessons Exercises
XPath: Locate Elements Using XPath online course

About this course

XPath is a query language for selecting nodes in an HTML or XML document. In test automation you use it to find an element by its tag, its visible text, or an attribute, and to walk up or across the tree when there is no clean id or class to grab. This course covers XPath for locating elements, with live practice on every query you write.

Common XPath expressions

Expression Selects
//button every button on the page
//input[@name='email'] the input whose name is email
//*[text()='Log in'] any element whose text is "Log in"
//label[.='Email']/following::input[1] the first input after the Email label
(//tr)[2] the second table row

A quick example

# A button found by its visible text, not a brittle id
//button[normalize-space()='Add to cart']

The course goes further into axes, predicates, and when a CSS selector is the better choice, all with instant feedback.

Course Content

0 Getting Started
1 lesson 3 min
28 lessons Total 1h 20 min total duration

About your instructor

Roy de Kleijn, Testsmith instructor

Roy de Kleijn · Software testing trainer

Roy de Kleijn has more than 15 years of hands-on experience in software testing and test automation. He writes and maintains every Testsmith course, so what you practise matches how the work is really done.

Connect on LinkedIn

Questions?

Contact us if you have any questions about this course.

Contact us

Frequently asked questions

Use the text test, for example //button[text()='Save']. Because stray spaces often break an exact match, normalize-space() is safer: //button[normalize-space()='Save']. This finds the button by what the user actually reads, which tends to be more stable than an id.

Reach for XPath when you need to match on visible text, or walk up and across the tree, for example from a label to its input. CSS is usually shorter and faster for id, class, and attribute matches, so many testers try CSS first and keep XPath for the harder cases.

Axes describe direction through the document, such as parent, following, preceding, and ancestor. They let you start from an element you can find easily, like a label, and step to a related one that has no clean selector of its own. The course covers the axes you actually use in testing.

Yes. You get videos, quizzes, and hands-on labs, and you work through them at your own pace, with no fixed schedule.

No. The hands-on labs for this course run in your browser, so you can start practising straight away without any local setup.

Yes. You earn a certificate of completion when you finish the course.

Software testers and QA engineers who want practical, job-ready skills, from the fundamentals through to a real project.