From the course: Playwright Python and Pytest for Web Automation Testing: Master Modern Web Testing with Playwright and Pytest in Python
Unlock this course with a free trial
Join today to access over 25,200 courses taught by industry experts.
Locators XPath
In the previous lessons, we learned about the CSS selectors. In this one, we'll learn about the XPath. That is the XML querying language, which is specifically created to select web elements. Now XPath is a bit tougher, but provides more functionality than CSS selectors. So to use the same, we'll go ahead and try to select web elements based on their tag name and their attribute and its corresponding value. So let's say what we'd like to do is select the title of the website. Why? I'll just tell you that in a moment. Because with XPath, what we do is select things with path. What that means is that we can start from the very head of the element or the root of the document that is HTML itself and we use slashes to start and separate selectors or things. Let's say we'd like to start from the root. So we use a slash and type in the tag name of the root that is HTML. You can see it is selected. Then we need to go inside of the head. You can see it is selected. And then inside of the head,…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
(Locked)
Playwright Python REPL8m 40s
-
(Locked)
Locator role8m 26s
-
(Locked)
Locators input field3m 39s
-
(Locked)
Locator text4m 6s
-
(Locked)
Locator alt text2m 22s
-
(Locked)
Locator title1m 56s
-
(Locked)
Locating with CSS selectors10m 7s
-
(Locked)
CSS selectors hierarchy8m 10s
-
(Locked)
CSS selectors pseudo classes9m
-
(Locked)
Locators XPath6m 5s
-
(Locked)
XPath functions7m 4s
-
(Locked)
Other locators10m 59s
-
(Locked)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-