playwright
playwright copied to clipboard
[BUG] `page.waitForEvent`: `framenavigated` overload clashes with `worker` overload
System info
- Playwright Version: 1.32.3
Source code
- [x] I provided exact source code that allows reproducing the issue locally.
test('tests dgozman iframe suggestion', async ({ page }) => {
// Expect an iframe with a specific url.
const framePromise = page.waitForEvent('framenavigated', {
// ^ No overload matches this call.
// The last overload gave the following error.
// Argument of type '"framenavigated"' is not assignable to parameter of type '"worker"'.ts(2769)
predicate: (frame: Frame) => frame.url().match(/vercel/),
});
// Load the page and wait for the iframe to appear.
await page.goto('/');
const frame = await framePromise;
// Click the button inside the iframe.
await frame.getByRole('button').last().click();
await frame.locator('text=Disable for Session').click();
await page.pause();
});
Steps
- Use this source code in a TypeScript project
- See TypeScript complain about the
page.waitForEventoverload
The type definitions (node_modules/playwright-core/types/types.d.ts):
waitForEvent(
event: 'framenavigated',
optionsOrPredicate?: {
predicate?:
| (frame: Frame) => boolean | Promise<boolean>, timeout?: number } |
| ((frame: Frame) => boolean | Promise<boolean>)
): Promise<Frame>;
waitForEvent(
event: 'worker',
optionsOrPredicate?: {
predicate?:
| (worker: Worker) => boolean | Promise<boolean>, timeout?: number }
| ((worker: Worker) => boolean | Promise<boolean>)
): Promise<Worker>;
Expected
No complaints.
Actual
Complaints.