22. iFrames, Multi-Tabs & Native JavaScript Dialogs

frameLocator API

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

// Multi-tabs:
const pagePromise = context.waitForEvent("page");
await page.getByRole("link", { name: "Open Terms" }).click();
const newPage = await pagePromise;
await expect(newPage).toHaveTitle(/Terms of Service/);

// Dialogs:
page.on("dialog", async (dialog) => {
await dialog.accept();
});

Task

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