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.
Other locators
Over the past few lessons we have gone through many locators and selectors. In this lesson we will go over the other miscellaneous locators and selectors which are available to us and can come in handy when we are trying to locate web elements. The first one is the nth selectors that is based on a number. So let's say what we want to do is select all the buttons with the primary written on it. So we can simply use the get by role selector. And then we can simply say something like the role is button, the name is primary. And then try to highlight all of them. You can see they are highlighted, but there are four of these buttons. Now what if we want to select the second button that is a bit faded. To do that, we can just use page, the same selector we did in the upper line, and then instead of the highlight, we will add another selector by just adding a dot and then using the locator and to the locator string we'll provide the keyword nth that is any numbered element that is first…
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)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-