0

I have below scenario -

  1. Launch browser and do some operations
  2. Click on a button, a new tab opens
  3. switch to new tab.
  4. In new tab, switch to iframe and perform operations inside frame.

How can I handle this in playwright? Once I switch to new tab, all elements are inside frame, so I want to switch to new frame after switching to new tab

Note - Frame doesn't have name. I can use xpath to identify frame.

will page.frame("xpath to iframe") work?

If anyone can provide small code snippet, would be really helpful.

I Tried using page.frame("xpath locator to iframe") - but not working

sumit
  • 91
  • 1
  • 1
  • 5

1 Answers1

0

You can switch to the new tab like this.

const [newTab] = await Promise.all([
  page.waitForEvent('popup'),
  page.locator('your locator here').click(),
]);

await newTab.waitForLoadState();
itronic1990
  • 1,231
  • 2
  • 4
  • 18