Lesson 6: Handle Frames and Windows

Frames & Multiple Tabs

Frames and Windows

Frames and Windows

1. Handling iFrames

iFrames are documents embedded inside another document.

javascript

const frame = page.frameLocator('#my-iframe');

await frame.getByRole('button').click();

2. Multiple Windows/Tabs

Handle popups or links that open in new tabs.

javascript

const [newPage] = await Promise.all([

context.waitForEvent('page'),

page.click('a[target="_blank"]')

]);

console.log(await newPage.title());

    CareerRaah - AI Learning Platform for Professionals