TOPIC 15/2216 MINNOT STARTED

Selenium: frames, new windows and tabs, and alert pop-ups

Reach elements inside a frame, move between windows and tabs, and handle browser alert pop-ups, so the "no such element" error stops fooling you.

L1–L4 are part of the Pro pass

L0 Explain simply

Analogy: three kinds of door. One door opens into a room inside the room. One door opens a second shop entrance. One door is a pop-up that blocks the hall until you answer it.

Tom separates three contexts in synthetic Daily List. A selects an embedded document. A selects another top-level tab/window by its handle. A browser alert is a native JavaScript alert/confirm/prompt, not an HTML dialog drawn by the app.

Looking through the wrong door can explain a failed lookup, but it is only one possible explanation. Check the known fixture and actual context before asserting that every missing element is in a frame.

The picture has a limit. Switching changes WebDriver's browsing context, not a guarantee of operating-system focus or business correctness. Restore the intended context after the operation.

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

PLAIN WORDS · 1 in this section
correctness
being free of mistakes

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 Select the correct frame, window or dialog context and verify the intended business outcome.

  1. Room
  2. Door
  3. Bell
House

HOW THE PICTURE MAPS

How each part of the picture matches the software
In the pictureIn the software
A roomA frame
Walking into the roomA frame switch
A second doorA new window or tab
A doorbellA browser alert

WHERE THIS PICTURE STOPS

  • A visible control can be in another context, but not every failed lookup is a frame problem.
  • Handle order is arbitrary in the named WebDriver Recommendation; a context switch is not a business-success oracle.

HOOK

Room, door, bell.

TELL A FRIEND

Rooms, a second door and a bell.

OFTEN MIXED UP WITH Selenium locators: find elements in a way that survives change. That topic finds elements on the page. This one handles frames, new windows and alert pop-ups, where a locator is not enough.

Sources & standards — 4 sources
  1. Implementation-specific

    Working with frames and iframes ↗ — Selenium project · Python frame-element switch example; leaving a frame to default content (selected actual primary passages read 7 November 2026; live publisher documentation; no fixed edition claimed).

    Python frame-element switch example; leaving a frame to default content. Named standard/version or product-specific guidance only; no universal employer practice inferred. · Checked 2026-11-07

    Selected actual primary passages read on the access date, not every linked guide. Live documentation, tagged package metadata and W3C2018 have distinct scopes. Daily List rules, people, identifiers and observations are synthetic. Educational sequences do not claim installation, vendor-package or live-app execution.

  2. Implementation-specific

    Working with windows and tabs ↗ — Selenium project · Original handle; before/after handles; closing and returning to surviving context (selected actual primary passages read 7 November 2026; live publisher documentation; no fixed edition claimed).

    Original handle; before/after handles; closing and returning to surviving context. Named standard/version or product-specific guidance only; no universal employer practice inferred. · Checked 2026-11-07

    Selected actual primary passages read on the access date, not every linked guide. Live documentation, tagged package metadata and W3C2018 have distinct scopes. Daily List rules, people, identifiers and observations are synthetic. Educational sequences do not claim installation, vendor-package or live-app execution.

  3. Implementation-specific

    JavaScript alerts, prompts and confirmations ↗ — Selenium project · Alert; Confirm; Prompt: text, accept, dismiss and input distinctions (selected actual primary passages read 7 November 2026; live publisher documentation; no fixed edition claimed).

    Alert; Confirm; Prompt: text, accept, dismiss and input distinctions. Named standard/version or product-specific guidance only; no universal employer practice inferred. · Checked 2026-11-07

    Selected actual primary passages read on the access date, not every linked guide. Live documentation, tagged package metadata and W3C2018 have distinct scopes. Daily List rules, people, identifiers and observations are synthetic. Educational sequences do not claim installation, vendor-package or live-app execution.

  4. Official requirement

    WebDriver — W3C Recommendation 5 June 2018 ↗ — World Wide Web Consortium (W3C) · Sections10.4 Get Window Handles,10.5 Switch To Frame and10.6 Switch To Parent Frame (selected actual primary passages read 7 November 2026; W3C Recommendation 5 June 2018, not later drafts).

    Sections10.4 Get Window Handles,10.5 Switch To Frame and10.6 Switch To Parent Frame. Named standard/version or product-specific guidance only; no universal employer practice inferred. · Checked 2026-11-07

    Selected actual primary passages read on the access date, not every linked guide. Live documentation, tagged package metadata and W3C2018 have distinct scopes. Daily List rules, people, identifiers and observations are synthetic. Educational sequences do not claim installation, vendor-package or live-app execution.

PRACTISE AND KEEP

Sources for this topic — 4 sources
  1. Implementation-specific

    Working with frames and iframes ↗ — Selenium project · Python frame-element switch example; leaving a frame to default content (selected actual primary passages read 7 November 2026; live publisher documentation; no fixed edition claimed).

    Python frame-element switch example; leaving a frame to default content. Named standard/version or product-specific guidance only; no universal employer practice inferred. · Checked 2026-11-07

    Selected actual primary passages read on the access date, not every linked guide. Live documentation, tagged package metadata and W3C2018 have distinct scopes. Daily List rules, people, identifiers and observations are synthetic. Educational sequences do not claim installation, vendor-package or live-app execution.

  2. Implementation-specific

    Working with windows and tabs ↗ — Selenium project · Original handle; before/after handles; closing and returning to surviving context (selected actual primary passages read 7 November 2026; live publisher documentation; no fixed edition claimed).

    Original handle; before/after handles; closing and returning to surviving context. Named standard/version or product-specific guidance only; no universal employer practice inferred. · Checked 2026-11-07

    Selected actual primary passages read on the access date, not every linked guide. Live documentation, tagged package metadata and W3C2018 have distinct scopes. Daily List rules, people, identifiers and observations are synthetic. Educational sequences do not claim installation, vendor-package or live-app execution.

  3. Implementation-specific

    JavaScript alerts, prompts and confirmations ↗ — Selenium project · Alert; Confirm; Prompt: text, accept, dismiss and input distinctions (selected actual primary passages read 7 November 2026; live publisher documentation; no fixed edition claimed).

    Alert; Confirm; Prompt: text, accept, dismiss and input distinctions. Named standard/version or product-specific guidance only; no universal employer practice inferred. · Checked 2026-11-07

    Selected actual primary passages read on the access date, not every linked guide. Live documentation, tagged package metadata and W3C2018 have distinct scopes. Daily List rules, people, identifiers and observations are synthetic. Educational sequences do not claim installation, vendor-package or live-app execution.

  4. Official requirement

    WebDriver — W3C Recommendation 5 June 2018 ↗ — World Wide Web Consortium (W3C) · Sections10.4 Get Window Handles,10.5 Switch To Frame and10.6 Switch To Parent Frame (selected actual primary passages read 7 November 2026; W3C Recommendation 5 June 2018, not later drafts).

    Sections10.4 Get Window Handles,10.5 Switch To Frame and10.6 Switch To Parent Frame. Named standard/version or product-specific guidance only; no universal employer practice inferred. · Checked 2026-11-07

    Selected actual primary passages read on the access date, not every linked guide. Live documentation, tagged package metadata and W3C2018 have distinct scopes. Daily List rules, people, identifiers and observations are synthetic. Educational sequences do not claim installation, vendor-package or live-app execution.

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.