Back to Browse

Playwright Python - XPath Locator

4.4K views
Jul 14, 2023
6:04

In this video you'll learn how to locate web elements using xpath. XPath is a language used to navigate and select elements in an XML or HTML document. It provides a concise syntax for locating elements based on their attributes, relationships, and positions within the document structure. If you absolutely must use CSS or XPath locators, you can use `page.locator()` to create a locator that takes a selector describing how to find an element in the page. Playwright supports CSS and XPath selectors, and auto-detects them if you omit css= or xpath= prefix. 🔧 When to use? CSS and XPath are not recommended as the DOM can often change leading to non resilient tests. Instead, try to come up with a locator that is close to how the user perceives the page such as role locators or define an explicit testing contract using test ids. ✨ Full Playwright Course 🎭 - https://bit.ly/playwright-auto ✨ CSS & XPath Masterclass 🔍 - https://bit.ly/css-xpath-masterclass Playwright is a modern, fast and reliable browser automation tool from Microsoft that enables testing and automation across all modern browsers including chromium, firefox and webkit.

Download

1 formats

Video Formats

360pmp48.2 MB

Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.

Playwright Python - XPath Locator | NatokHD