Playwright with Java Tutorial Home / Video /

Playwright Java Tutorial 🎭 | How To Handle Windows, Tabs, And Popups | Part VIII

Playwright Java Tutorial 🎭 | How To Handle Windows, Tabs, And Popups | Part VIII

About the Video

With this Part 8 of the Playwright Java tutorial series, Koushik Chatterjee (@Koushik_chat), Content Creator at LetCode gives a comprehensive understanding of window handling in Playwright with Java, including switching between tabs and effectively interacting with multiple tabs for enhanced web application testing.

Video Chapters

00:00 Introduction

00:30 What is window handling?

03:00 How to switch to a new tab?

07:14 Wait for the title change

10:47 How to interact with popups?

12:20 How to handle multiple tabs?

15:30 WaitForPopupOptions

21:20 Recap

Key Topics Covered

Introduction to Window Handling: Kaushik explains the concept of window handling, distinguishing between pop-ups (modal alerts) that do not require switching context and new tabs or windows that do. He clarifies that tabs and windows are technically the same from a browser's perspective.

Basic Window Handling: The tutorial begins with how to handle a single new tab/window. Kaushik demonstrates how to click on a link that opens a new tab and how to switch to this new tab using Playwright's context management, without the need for the driver.switchTo().window() method used in Selenium.

Handling Multiple Tabs: Kaushik progresses to handling multiple tabs opened by a single action. He illustrates how to manage multiple windows by capturing all open tabs within a browser context and iterating through them to perform actions or assertions.

Distinguishing Between Browser Context and Window Handling: It's highlighted that browser context and window handling are distinct concepts in Playwright. Browser context pertains to sessions, cookies, and cache, whereas window handling deals with managing multiple tabs/windows within the same context.

Practical Examples and Code Demonstrations: Through practical examples, such as clicking on links that open new tabs and handling pop-up windows, Kaushik provides code snippets and detailed explanations on how to interact with elements within these new contexts.

Advanced Window Handling Techniques: The tutorial covers advanced scenarios like handling pop-ups that are actual new windows and interacting with elements within these windows. Kaushik shows how to use listeners and assertions to wait for specific conditions, such as a page load or title change, before proceeding with further actions.

Recap and Best Practices: The video concludes with a recap of the window handling techniques discussed and emphasizes best practices for managing multiple windows or tabs in Playwright. Kaushik advises against having too many tabs open as it can complicate automation scripts and suggests discussing with UI/UX designers if such scenarios are necessary.

Related Blogs & Hubs

Playwright vs Selenium vs Cypress: A Detailed Comparison

Playwright Tutorial: Getting Started With Playwright Framework

How To Find Elements Using Playwright Locators

A Complete Guide To Playwright Assertions

Testing Modern Applications With Playwright

Playwright End To End Testing Tutorial: A Complete Guide

More Videos from Playwright with Java Tutorial