New in Playwright: detect and close unpredictable overlays with "addLocatorHandler"

New in Playwright: detect and close unpredictable overlays with "addLocatorHandler"

Mar 8, 2024

Discover the latest feature of Playwright 1.42 — `page.addLocatorHandler`.

If you're tired of randomly appearing cookie banners breaking your end-to-end tests or want to automatically close all these intercom widgets, this method is right up your alley. With `addLocatorHandler`, handling elements that randomly pop up becomes a breeze!

In the video, we'll show you how the new Playwright method works in practice and why it makes end-to-end testing and synthetic monitoring so much easier.

0:00 Intro

0:35 The problem of unpredictable elements

1:16 Playwright UI mode

1:55 Cookie banner example

2:39 Close cookie banner with try/catch

3:44 try/catch problems

5:31 addLocatorHandler intro

6:29 addLocatorHandler in UI mode

7:43 addLocatorHandler details

9:35 Outro

Playwright Docs: https://playwright.dev/docs/api/class-page#page-add-locator-handler
Checkly Synthetic Monitoring: https://www.checklyhq.com/product/synthetic-monitoring/
Checkly Community: https://www.checklyhq.com/slack/

#playwright #testing #monitoring