Skip to content

Commit

Permalink
fix: use handle frame instead of page (#10676)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrandolf committed Aug 3, 2023
1 parent 9a814a3 commit 1b44b91
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/puppeteer-core/src/api/locators/Locator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ export abstract class Locator<T> extends EventEmitter {
return EMPTY;
}
return from(
handle.frame.page().waitForFunction(
handle.frame.waitForFunction(
element => {
if (!(element instanceof HTMLElement)) {
return true;
Expand Down
6 changes: 6 additions & 0 deletions test/TestExpectations.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
25 changes: 25 additions & 0 deletions test/src/locator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(`
<iframe src="data:text/html,<button onclick=&quot;this.innerText = 'clicked';&quot;>test</button>"></iframe>
`);
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 () {
Expand Down

0 comments on commit 1b44b91

Please sign in to comment.