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.
CSS selectors pseudo classes
From the course: Playwright Python and Pytest for Web Automation Testing: Master Modern Web Testing with Playwright and Pytest in Python
CSS selectors pseudo classes
In the previous lesson, we learned about how can we use CSS selectors to locate web elements. In this lesson, we'll learn about the pseudo classes which playwright offers to use and select web elements based on different conditions. So let's say we want to do is select all the heading elements in the page. So we will likely use the page locator, specify the tag name which will be h1 and then just highlight all of the instances. You can see these are all the headings with the h1 tag name. Now let's say what we want to do is only select this heading element with the nav bars text. Now here what we can do is just use the get by text locator. But if you really want to use the CSS one instead, then we can just use the text pseudo class which playwright offers. Now pseudo class is just like a function which we can run on any CSS selector like this one. So let's go ahead and do that. So we'll start with our CSS selector that is H1 and now because we want to use a pseudo class, what we do is…
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)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-