diff --git a/packages/puppeteer-core/src/api/locators/Locator.ts b/packages/puppeteer-core/src/api/locators/Locator.ts index 8ff4c73465d..19a769c7f0c 100644 --- a/packages/puppeteer-core/src/api/locators/Locator.ts +++ b/packages/puppeteer-core/src/api/locators/Locator.ts @@ -322,7 +322,7 @@ export abstract class Locator extends EventEmitter { return EMPTY; } return from( - handle.frame.page().waitForFunction( + handle.frame.waitForFunction( element => { if (!(element instanceof HTMLElement)) { return true; diff --git a/test/TestExpectations.json b/test/TestExpectations.json index 87a73c02925..161e1a69406 100644 --- a/test/TestExpectations.json +++ b/test/TestExpectations.json @@ -965,6 +965,12 @@ "parameters": ["webDriverBiDi"], "expectations": ["PASS"] }, + { + "testIdPattern": "[locator.spec] Locator Locator.click should work with a OOPIF", + "platforms": ["darwin", "linux", "win32"], + "parameters": ["webDriverBiDi"], + "expectations": ["FAIL"] + }, { "testIdPattern": "[mouse.spec] Mouse should click the document", "platforms": ["darwin", "linux", "win32"], diff --git a/test/src/locator.spec.ts b/test/src/locator.spec.ts index d0288a43152..1cd518e7b70 100644 --- a/test/src/locator.spec.ts +++ b/test/src/locator.spec.ts @@ -287,6 +287,31 @@ describe('Locator', function () { clock.restore(); } }); + + it('should work with a OOPIF', async () => { + const {page} = await getTestState(); + + await page.setViewport({width: 500, height: 500}); + await page.setContent(` + + `); + const frame = await page.waitForFrame(frame => { + return frame.url().startsWith('data'); + }); + let willClick = false; + await frame + .locator('button') + .on(LocatorEmittedEvents.Action, () => { + willClick = true; + }) + .click(); + const button = await frame.$('button'); + const text = await button?.evaluate(el => { + return el.innerText; + }); + expect(text).toBe('clicked'); + expect(willClick).toBe(true); + }); }); describe('Locator.hover', function () {