12. iFrames, Multi-Tabs & Native Popups

iFrames with frameLocator

// Locate elements directly inside an iframe:
const paymentFrame = page.frameLocator("#stripe-frame");
await paymentFrame.getByLabel("Card Number").fill("4242 4242 4242 4242");

// Multi-tabs:
const newPagePromise = context.waitForEvent("page");
await page.getByRole("link", { name: "Help Center" }).click();
const newPage = await newPagePromise;
await expect(newPage).toHaveTitle(/Help/);

Task

  • Implement validateDialogType:
  • 1. Accept dialogType string.
  • 2. Return true if dialogType is "alert", "confirm", or "prompt".
πŸ’‘Common doubts
Did you like the problem?
Lesson 12 of 18
JavaScript
Loading code editor…
Next