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 alt text
In this lesson, we'll learn how can we use the get by alt text locator to locate images. So first of all, we'll like some images to locate. So let's go to unsplash.com. You will find the link of the same in the resources. You can see it is a free images site with a lot of images, which we can select. So let's say we'd like to select this image right here. And if you're not familiar with it, HTML images always come with a alt property that is like a textual description of the image. That is, you can see this image right here has some people with some fruits. And if I read the alt text, you can see it says a group of people sitting around a table with food. So what we can do is just copy it. And now we would like to select this image based on its alt text. So we can use page get by alt text and provide it the alternative text, which is this right here. And now I can just go ahead and select it. And then let's highlight it as well. Hit enter. You can see the image gets highlighted…
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)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-