O'Reilly logo

Selenium Testing Tools Cookbook by Unmesh Gundecha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Identifying and handling a pop-up window by its content

In certain situations, developers neither assign the name attribute nor provide a title to the page displayed in a pop-up window. This becomes more complex when a test needs to deal with multiple pop-up windows open at the same time—to identify the desired pop-up window.

Ideally, you should reach out to developers and recommend that they add either the name attribute or title for better testability and accessibility.

As a workaround to this problem, we can check the contents of each window returned by the driver.getWindowHandles() method to identify the desired pop-up window.

How to do it...

Let's create a test that retrieves the handles of all the open windows in the current driver context. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required