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.
- Room
- Door
- Bell
HOW THE PICTURE MAPS
| In the picture | In the software |
|---|---|
| A room | A frame |
| Walking into the room | A frame switch |
| A second door | A new window or tab |
| A doorbell | A 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
- 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).
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.
- 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).
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.
- 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).
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.
- 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).
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
- 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).
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.
- 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).
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.
- 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).
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.
- 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).
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.