fix: use handle frame instead of page (#10676)

This commit is contained in:
jrandolf 2023-08-03 12:11:44 +02:00 committed by GitHub
parent 9a814a3656
commit 1b44b911d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 1 deletions

View File

@ -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;

View File

@ -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"],

View File

@ -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 () {