Rayrun
← Back to videos

#17 - New Advanced Locator Strategy in Playwright

In this video, we will discuss the new Advanced and more flexible Playwright Locator Strategy introduced to identify and locate UI elements in DOM in a much more readable and understandable fashion.

In this video, we explore how Playwright, a powerful automation tool for web applications, handles a new locator strategy, allowing for a more seamless process of finding and interacting with web elements. We also examine the built-in locators provided by Playwright, which include getByRole, getText, getByLabel, and many others.

We begin by demonstrating how to examine a web application's support for ARIA (Accessible Rich Internet Applications) locators through the use of Chrome DevTools. This allows us to determine if any ARIA attributes are available to be used as locators. We then proceed to show how to use Playwright to locate elements by their ARIA attributes and perform various actions, such as entering text into input fields and clicking buttons.

Next, we demonstrate how to use Playwright's code generator, a powerful feature that allows users to record their interactions with a web application and generate corresponding Playwright script for later use. This comes in handy for automating tasks or conducting testing.

Finally, we discuss how to chain multiple locators together for more complex scenarios, such as when a web element does not have a readily identifiable attribute. Using this chaining technique, we're able to create more granular locators and better control our interactions with web elements.

In summary, Playwright's new locator strategy, along with its code generation capabilities and the ability to chain locators together, provides a powerful and versatile foundation for automating tasks and testing web applications. This ultimately results in more efficient and streamlined workflows for developers and testers alike.

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?
Generating Playwright Tests in VS Code
Generating Playwright Tests in VS Code
Playwright - Set timeout, parallelisation and retries directly in your test files
Playwright - Set timeout, parallelisation and retries directly in your test files
Playwright VsCode Extension
Playwright VsCode Extension
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.