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.
Locator text
In this lesson, we'll learn about the get by text locator, which helps you locate elements based on their text. Let's say we'd like to select this with muted text. So let's go ahead and inspect it. You can see it's a small element inside H3 with the text as with muted text. So what we can do is do page get by text and just provide it the text. In this case it is with muted text. And we can just go ahead and say highlight it. You can see that gets highlighted. Now of course you would not like to select just a certain piece of text. Instead you can apply the same technique on other elements like links and buttons as well. So what you can do is just say like get by text and let's say we like to have this small button. So I can just say like small button and then I can just say highlight it. You can see small button gets highlighted. Similarly we can select other elements as well. Let's say we'd like to select a button that is this middle right here. So if I click it, you can see for a…
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)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-