fix: fix method elementHandle.frameElement() for framesets (#6468)
Playwright clicks did not work in regular frames due to a bug in `frameElement` method. Fixes #6453
This commit is contained in:
parent
f1a65820f4
commit
5c1ddc7f0a
|
|
@ -541,7 +541,7 @@ export class FFPage implements PageDelegate {
|
|||
const parent = frame.parentFrame();
|
||||
if (!parent)
|
||||
throw new Error('Frame has been detached.');
|
||||
const handles = await this._page.selectors._queryAll(parent, 'iframe', undefined);
|
||||
const handles = await this._page.selectors._queryAll(parent, 'frame,iframe', undefined);
|
||||
const items = await Promise.all(handles.map(async handle => {
|
||||
const frame = await handle.contentFrame().catch(e => null);
|
||||
return { handle, frame };
|
||||
|
|
|
|||
|
|
@ -895,7 +895,7 @@ export class WKPage implements PageDelegate {
|
|||
const parent = frame.parentFrame();
|
||||
if (!parent)
|
||||
throw new Error('Frame has been detached.');
|
||||
const handles = await this._page.selectors._queryAll(parent, 'iframe', undefined);
|
||||
const handles = await this._page.selectors._queryAll(parent, 'frame,iframe', undefined);
|
||||
const items = await Promise.all(handles.map(async handle => {
|
||||
const frame = await handle.contentFrame().catch(e => null);
|
||||
return { handle, frame };
|
||||
|
|
|
|||
|
|
@ -40,6 +40,14 @@ it('should work with contentFrame', async ({page, server}) => {
|
|||
expect(contentFrame).toBe(frame);
|
||||
});
|
||||
|
||||
it('should work with frameset', async ({page, server}) => {
|
||||
await page.goto(server.PREFIX + '/frames/frameset.html');
|
||||
const frameElement1 = await page.$('frame');
|
||||
const frame = await frameElement1.contentFrame();
|
||||
const frameElement2 = await frame.frameElement();
|
||||
expect(await frameElement1.evaluate((a, b) => a === b, frameElement2)).toBe(true);
|
||||
});
|
||||
|
||||
it('should throw when detached', async ({page, server}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
const frame1 = await attachFrame(page, 'frame1', server.EMPTY_PAGE);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,16 @@ it('should click the button', async ({page, server}) => {
|
|||
expect(await page.evaluate('result')).toBe('Clicked');
|
||||
});
|
||||
|
||||
it('should click button inside frameset', async ({page, server}) => {
|
||||
await page.goto(server.PREFIX + '/frames/frameset.html');
|
||||
const frameElement = await page.$('frame');
|
||||
await frameElement.evaluate(frame => frame.src = '/input/button.html');
|
||||
const frame = await frameElement.contentFrame();
|
||||
await frame.click('button');
|
||||
expect(await frame.evaluate('result')).toBe('Clicked');
|
||||
});
|
||||
|
||||
|
||||
it('should click svg', async ({page}) => {
|
||||
await page.setContent(`
|
||||
<svg height="100" width="100">
|
||||
|
|
|
|||
Loading…
Reference in New Issue