Identifying and handling a pop-up window by its name

In Selenium WebDriver, testing pop-up windows involves identifying a pop-up window, switching the driver context to the pop-up window, then executing steps on the pop-up window, and finally switching back to the parent window.

The Selenium WebDriver allows us to identify a pop-up window by its name attribute or window handle and switching between the pop-up window and the browser window is done using the Webdriver.switchTo().window() method.

In this recipe, we will identify and handle a pop-up window by using its name attribute. Developers provide the name attribute for a pop-up window that is different from its title. In the following example, a user can open a pop-up window by clicking on the ...

Get Selenium Testing Tools Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.