lecture 14 of 200 completed

Multiple tabs and pop-up windows

A link that opens a new tab breaks a naive test. Playwright makes you catch the new page before it appears.

What you'll learn

  • How to catch a tab that opens from a click
  • Why the listener has to start before the click
  • When not to test the new tab at all

A test clicks "View invoice" and then looks for the invoice number. It fails, saying the element is not there.

The invoice opened in a new tab. Your test is still looking at the old one. Playwright did not follow the click, because pages do not automatically become the active one.

The fix has one detail that catches everybody, so read the order carefully.

full course

Keep reading with the full course

The Foundations track and the first lessons in each framework are free. This lesson needs full course access. A course plan includes all lessons for Playwright, Cypress and Selenium.

See course plans →