Skip to content

Commit e7f0635

Browse files
cherry-pick(#29692): docs: better addLocatorHandler example in release notes (#29697)
This PR cherry-picks the following commits: - 321e9d7
1 parent 8709a3a commit e7f0635

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

docs/src/release-notes-js.md

+8-6
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ import LiteYouTube from '@site/src/components/LiteYouTube';
1313
- 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:
1414
```js
1515
// Setup the handler.
16-
await page.addLocatorHandler(page.getByRole('button', { name: 'Accept all cookies' }), async () => {
17-
await page.getByRole('button', { name: 'Reject all cookies' }).click();
18-
});
19-
16+
await page.addLocatorHandler(
17+
page.getByRole('heading', { name: 'Hej! You are in control of your cookies.' }),
18+
async () => {
19+
await page.getByRole('button', { name: 'Accept all' }).click();
20+
});
2021
// Write the test as usual.
21-
await page.goto('https://example.com');
22-
await page.getByRole('button', { name: 'Start here' }).click();
22+
await page.goto('https://www.ikea.com/');
23+
await page.getByRole('link', { name: 'Collection of blue and white' }).click();
24+
await expect(page.getByRole('heading', { name: 'Light and easy' })).toBeVisible();
2325
```
2426

2527
- `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)

0 commit comments

Comments
 (0)