From e7f0635c17ac5c178b0960cb35f849edd3cf69ef Mon Sep 17 00:00:00 2001 From: Playwright Service <89237858+playwrightmachine@users.noreply.github.com> Date: Tue, 27 Feb 2024 11:05:24 -0800 Subject: [PATCH] cherry-pick(#29692): docs: better addLocatorHandler example in release notes (#29697) This PR cherry-picks the following commits: - 321e9d72c35090e036f3be430ad022b5192fced8 --- docs/src/release-notes-js.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/src/release-notes-js.md b/docs/src/release-notes-js.md index 16ad193eba9df..3320a0d14e89a 100644 --- a/docs/src/release-notes-js.md +++ b/docs/src/release-notes-js.md @@ -13,13 +13,15 @@ import LiteYouTube from '@site/src/components/LiteYouTube'; - New method [`method: Page.addLocatorHandler`] registers a callback that will be invoked when specified element becomes visible and may block Playwright actions. The callback can get rid of the overlay. Here is an example that closes a cookie dialog when it appears: ```js // Setup the handler. -await page.addLocatorHandler(page.getByRole('button', { name: 'Accept all cookies' }), async () => { - await page.getByRole('button', { name: 'Reject all cookies' }).click(); -}); - +await page.addLocatorHandler( + page.getByRole('heading', { name: 'Hej! You are in control of your cookies.' }), + async () => { + await page.getByRole('button', { name: 'Accept all' }).click(); + }); // Write the test as usual. -await page.goto('https://example.com'); -await page.getByRole('button', { name: 'Start here' }).click(); +await page.goto('https://www.ikea.com/'); +await page.getByRole('link', { name: 'Collection of blue and white' }).click(); +await expect(page.getByRole('heading', { name: 'Light and easy' })).toBeVisible(); ``` - `expect(callback).toPass()` timeout can now be configured by `expect.toPass.timeout` option [globally](./api/class-testconfig#test-config-expect) or in [project config](./api/class-testproject#test-project-expect)