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.
Mouse actions
In the previous section, we have learned different kinds of locators and selectors which can be used to locate web elements. In this section, we'll learn about the actions which we can perform in these located elements. We have already learned about the click action that is, let's say if you'd like to click this block button because it is large. So let's go ahead and create a locator for the same. So on the page object, we can use the get by role locator. And the locators role is a button, the name on it says, lock button like this. And if I go ahead and highlight the same, you can see we have highlighted two buttons, that is the first one and the second one. But because we only want the first one, what we can do is on the locator, we can access the first element using the first attribute. Similarly we can access the last one using the last attribute. So let's go ahead and access the first button and we will go ahead store it in the button variable and to remove the highlight I'll…
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.