docs: better addLocatorHandler example in release notes (#29692)
This commit is contained in:
parent
d8c16c1edf
commit
321e9d72c3
|
|
@ -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:
|
- 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
|
```js
|
||||||
// Setup the handler.
|
// Setup the handler.
|
||||||
await page.addLocatorHandler(page.getByRole('button', { name: 'Accept all cookies' }), async () => {
|
await page.addLocatorHandler(
|
||||||
await page.getByRole('button', { name: 'Reject all cookies' }).click();
|
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.
|
// Write the test as usual.
|
||||||
await page.goto('https://example.com');
|
await page.goto('https://www.ikea.com/');
|
||||||
await page.getByRole('button', { name: 'Start here' }).click();
|
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)
|
- `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)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue