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

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…

Contents