Skip to content

How to Handle Tabs and Windows in Selenium and Playwright

Practice browser tab and window automation — open new tabs, switch between windows, close tabs, handle popups, and assert URL and title in Playwright, Selenium & Cypress.

Intermediate14 min8 scenarios14 test cases

Interactive Scenarios

S01Scenario 1: Open Link in New Tab
🔗 Open in New Tabtarget="_blank"
No tab opened
S02Scenario 2: Open Multiple Tabs
No tabs opened
S03Scenario 3: Switch Back to Original Tab
↗ Open New Tab
Not switched
S04Scenario 4: Assert New Tab URL and Title
↗ Open & Assert URL + Title

Hint attributes: data-expected-url-contains, data-expected-title-contains

URL not asserted
S05Scenario 5: Close a Tab
↗ Open Tab
Tab not closed
S06Scenario 6: Window Popup (window.open)

Uses window.open() with explicit size — Playwright captures via page.waitForEvent('popup')

Popup not handled
S07Scenario 7: Sibling Tab Buttons (Medium)

Tab Launcher Panel

Sibling not located
S08Scenario 8: Dynamic Tab Registry (Challenge)CHALLENGE

No data-testid on rows or buttons. Use XPath by cell text or data-tab-id.

Tab NameURLStatusAction
Tab A/Open
Tab B/practiceOpen
Tab C/practice/linksOpen
Registry not asserted