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.
Locating with CSS selectors
From the course: Playwright Python and Pytest for Web Automation Testing: Master Modern Web Testing with Playwright and Pytest in Python
Locating with CSS selectors
In the previous lessons, we discussed about many locators, that is the get by role, get by label, get by text, and so on. In this lesson, we'll learn about the CSS selectors and how can we use them to locate web elements using playwright. Now, one thing I should mention before using CSS selectors is that playwright documentations recommend to use the locators over any other thing but you can always use other things like css selectors to select web elements because it provides more freedom when selecting web elements css selectors can be used to select web elements based on their tag name class name id or any attribute and its value so let's go ahead and see how can we do the same now to test css selectors we can use the dev tools and while being in dev tools hit ctrl and f and you will see a search bar like thing popping up in which we can test our selectors so let's say what we want to do is select all the heading elements in the page so let's just go ahead and highlight the element…
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)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-