TOPIC 21/6018 MINNOT STARTED

Frames, tabs, dialogs and popups

Reach inside frames, answer dialog boxes and follow a link into a new tab, with the Playwright calls that do each one and the mistakes to avoid.

L1–L4 are part of the Pro pass

L0 Explain simply

Analogy: rooms inside rooms, and doors that open a second room. A big house has a room with a glass box inside it. You cannot reach what is in the box by walking around the room. You must open the box first. Some doors lead to a second room. A guard may stop you and ask, "Are you sure?" You must answer before you walk on.

Daily List is a to-do list app. Its paid plan page has a card form. The form is a frame: a page inside the page. The Help link opens in a new tab. The Delete list button shows a dialog. The dialog asks "Delete this list?" and waits for an answer. Tom, the tester, must cope with all three.

The picture has limits. A house has fixed rooms. A page can open and close frames while you watch. A guard asks once. A page can ask many times.

What it is: Playwright is a free library from Microsoft that drives a real browser from code. The browsers are Chromium, Firefox and WebKit. This topic is one slice of that library: the calls for frames, dialogs and new tabs. A opens the glass box first, with page.frameLocator('iframe[title="Card form"]'). A answers the guard, with page.on('dialog', dialog => dialog.accept()). The word accept means press OK. A popup page is the new tab. You catch it with page.waitForEvent('popup'). These are Playwright calls, not a separate tool. The nearest neighbour is a plain locator such as page.getByLabel('Card number'). That locator cannot see inside a frame.

Why it matters: Without these calls, Tom's suite stops at the first card form, confirm box or Help link. A plain locator finds nothing inside a frame, so the test waits and then times out. By default Playwright presses Cancel on a confirm box. A Delete test would see the list still there. A click that opens a new tab leaves the test on the old tab. Each of these looks like a broken app. Mei can lose an afternoon chasing a fault that lives only in the test.

(SYNTHETIC / TRAINING ONLY: Daily List and every person named in this lesson are invented.)

PLAIN WORDS · 5 in this section
playwright
a free Microsoft tool that drives a browser for tests
chromium
the open-source browser engine behind Google Chrome
webkit
The browser engine behind Safari. Playwright can drive it.
locator
a pointer telling you where to find something
popup
A new window or tab that a page opens.

PICTURE IT

The picture is the one the lesson above opens with. The table below shows how each part of it matches the software.

THE REAL JOB Reaching things in a page inside a page, answering a browser box, and following a link into a new tab.

  1. Open the frame
  2. Answer the dialog
  3. Wait before the click
  4. Work in the new tab
Open, answer, catch

HOW THE PICTURE MAPS

How each part of the picture matches the software
In the pictureIn the software
The glass box in the roomThe iframe
Opening the box firstThe frame locator
The guard who asksThe dialog
The door to a second roomThe popup page

WHERE THIS PICTURE STOPS

  • A house has fixed rooms. A page can open and close frames while a test runs.
  • A guard asks one question. A page can ask many times.
  • A second room stays where it is. A new tab can close itself.

HOOK

Open the box, answer the guard, catch the door.

REMEMBER IT THIS WAY

A sequence: the real steps, in order.

Before you click, ask whether it is inside a frame, whether a dialog is waiting, and whether a new tab opened.

What each part of the trick stands for
In the trickWhat it stands for
Inside a frame?a page inside the page
Dialog waiting?a small box that asks and waits for an answer
New tab?the Help link opens in a new tab

TELL A FRIEND

Rooms inside rooms, with a guard and a door to a second room.

OFTEN MIXED UP WITH Frames, windows, pop-ups and uploads in UI checks. The general lesson explains why frames, windows and popups need care. This lesson shows the Playwright calls.

Sources & standards — 4 sources
  1. Market practice

    Locator (Playwright documentation) ↗ — Microsoft (Playwright) · Reviewed 6 November 2026: selectOption, setChecked, setInputFiles and tap. See v45 source analysis for version scope and documented source ambiguities; no upstream run claimed.

    Reference for locator.setInputFiles, which sets the files of a file input from paths or in-memory buffers, resolves relative paths from the working directory and clears the selection with an empty array; also frameLocator for content inside an iframe. Vendor documentation for one tool. Practitioner or vendor guidance, not a standard. · Checked 2026-11-06

    Primary source opened and operative text inspected on 6 November 2026. Scope: selectOption, setChecked, setInputFiles and tap. Current live Playwright documentation reflects 1.65 where stated; explicit older examples retain their version. Source inspection is not an execution or compatibility-test claim. See the completed v45 Playwright analysis for source discrepancies and exact reading boundaries.

  2. Market practice

    Dialogs (Playwright documentation) ↗ — Microsoft (Playwright) · alert, confirm and prompt dialogs are dismissed automatically by default; page.on dialog with accept and dismiss; a listener that does not handle the dialog leaves the page waiting; accept can take prompt text (search excerpt, page not opened)

    Says alert, confirm and prompt dialogs are dismissed automatically by default, shows page.on dialog with accept and dismiss, and warns that a listener which does not handle the dialog leaves the page waiting. Vendor documentation for one tool. Practitioner or vendor guidance, not a standard. · Checked 2026-10-18

    Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.

  3. Market practice

    Pages (Playwright documentation) ↗ — Microsoft (Playwright) · Start waiting for the popup event before the click that opens it, then wait for the popup to load; the context page event covers new tabs (search excerpt, page not opened)

    Describes handling new pages and popups: start waiting for the popup event before the click that opens it, then wait for the popup to load, and the context page event for new tabs. Vendor documentation for one tool. Practitioner or vendor guidance, not a standard. · Checked 2026-10-18

    Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.

  4. Market practice

    The iframe element (Mozilla developer docs, HTML reference) ↗ — Mozilla (developer documentation) · An iframe element embeds another HTML page inside the current page (search excerpt, page not opened)

    Per the search excerpt, an iframe embeds another document inside the current page as a nested browsing context. · Checked 2026-10-18

    Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.

PRACTISE AND KEEP

Sources for this topic — 5 sources
  1. Market practice

    Locator (Playwright documentation) ↗ — Microsoft (Playwright) · Reviewed 6 November 2026: selectOption, setChecked, setInputFiles and tap. See v45 source analysis for version scope and documented source ambiguities; no upstream run claimed.

    Reference for locator.setInputFiles, which sets the files of a file input from paths or in-memory buffers, resolves relative paths from the working directory and clears the selection with an empty array; also frameLocator for content inside an iframe. Vendor documentation for one tool. Practitioner or vendor guidance, not a standard. · Checked 2026-11-06

    Primary source opened and operative text inspected on 6 November 2026. Scope: selectOption, setChecked, setInputFiles and tap. Current live Playwright documentation reflects 1.65 where stated; explicit older examples retain their version. Source inspection is not an execution or compatibility-test claim. See the completed v45 Playwright analysis for source discrepancies and exact reading boundaries.

  2. Market practice

    Dialogs (Playwright documentation) ↗ — Microsoft (Playwright) · alert, confirm and prompt dialogs are dismissed automatically by default; page.on dialog with accept and dismiss; a listener that does not handle the dialog leaves the page waiting; accept can take prompt text (search excerpt, page not opened)

    Says alert, confirm and prompt dialogs are dismissed automatically by default, shows page.on dialog with accept and dismiss, and warns that a listener which does not handle the dialog leaves the page waiting. Vendor documentation for one tool. Practitioner or vendor guidance, not a standard. · Checked 2026-10-18

    Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.

  3. Market practice

    Pages (Playwright documentation) ↗ — Microsoft (Playwright) · Start waiting for the popup event before the click that opens it, then wait for the popup to load; the context page event covers new tabs (search excerpt, page not opened)

    Describes handling new pages and popups: start waiting for the popup event before the click that opens it, then wait for the popup to load, and the context page event for new tabs. Vendor documentation for one tool. Practitioner or vendor guidance, not a standard. · Checked 2026-10-18

    Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.

  4. Market practice

    The iframe element (Mozilla developer docs, HTML reference) ↗ — Mozilla (developer documentation) · An iframe element embeds another HTML page inside the current page (search excerpt, page not opened)

    Per the search excerpt, an iframe embeds another document inside the current page as a nested browsing context. · Checked 2026-10-18

    Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.

  5. Market practice

    Dialog (Playwright documentation) ↗ — Microsoft (Playwright) · Describes dialog.message(), dialog.type() (alert, beforeunload, confirm or prompt), dialog.accept(promptText) and dialog.dismiss() (search excerpt, page not opened)

    Describes dialog.message(), dialog.type() (alert, beforeunload, confirm or prompt), dialog.accept(promptText) and dialog.dismiss(). Vendor documentation for one tool. Practitioner or vendor guidance, not a standard. · Checked 2026-10-18

    Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.

Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.