Rayrun
← Back to videos

Element Handle VS Locator API | Playwright Tutorial - Part 47

Locator represents a view of the element(s) on the page. It captures the logic sufficient to retrieve the element at any given moment.

The video is a tutorial on three topics:

  1. The difference between using the straight and locator API, and how to use the element handle to interact with elements on a webpage.
  2. The usage and benefits of the nth function, which allows for interacting with multiple elements on a webpage.
  3. The advantages and recommended usage of the locator API over the element handle.

The video starts with an introduction and then dives into a demonstration of the concepts. The presenter shows how to use the element handle to interact with buttons on a webpage, and explains that by default, the element handle interacts with the first element it finds. However, if the same locator is used for multiple elements, it is necessary to use the straight parameter to either allow or prevent multiple interactions.

Next, the presenter introduces the locator API, which provides a more advanced way of interacting with elements on a webpage. They explain that the locator API refines the element each time it is used, which can be useful for scenarios where the elements on a webpage change dynamically. The presenter then demonstrates how to use the locator API to interact with multiple elements, and provides examples of how to count the number of elements found and how to print the text of each element.

The video concludes by highlighting the recommended usage of the locator API over the element handle, and encourages viewers to adopt the new changes in Playwright to enhance their frameworks. The presenter also welcomes feedback from viewers.

Related Videos

#16 - ARIA and how Playwright is making use of it to identify UI controls?
#16 - ARIA and how Playwright is making use of it to identify UI controls?
Playwright web table concept | Playwright Typescript tutorial - Part 92
Playwright web table concept | Playwright Typescript tutorial - Part 92
Playwright Version 1.14 | Playwright Tutorial - Part 45
Playwright Version 1.14 | Playwright Tutorial - Part 45
First Script - Auto Waits | Playwright - Part 3
First Script - Auto Waits | Playwright - Part 3
TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email luc@ray.run.