Skip to content
CodeKruPro

Handle Popup Window

51/70

Handle Popup Window

When a click opens a new tab/window, use page.waitForEvent('popup') to capture the new page.

On the Buttons page, clicking #openNewTab opens a new tab.

Task:

  1. Navigate to https://testkru.com/Elements/Buttons
  2. Set up page.waitForEvent('popup') before clicking
  3. Click #openNewTab
  4. Wait for the popup page, then print its URL
  5. Print the title of the original page

Expected output:

Popup URL: https://www.testkru.com/
Original title: Buttons