Controlling tabs that are opened after a click on an element on the page can be trickier. Let’s explore this through an example:
Navigating to https://checklyhq.com/docs.
Opening a new tab by clicking the link to the Checkly YouTube channel which opens in a new tab.
By allowing us to wait for the creation of a child tab with page.waitForEvent, Playwright enables us to “catch” it following a click on an element with target="_blank", and then seamlessly interact with any of the currently open tabs.