Identifying and handling a child window
In Selenium WebDriver, testing multiple windows involves identifying a window, switching the driver context to the window, then executing steps on the window, and finally, switching back to the browser.
The Selenium WebDriver allows us to identify a window by its name
attribute or window handle, and switching between the window and the browser window is done using the WebDriver.switchTo().window()
method of WebDriver.TargetLocator
.
In this recipe, we will identify and handle a window by using its name
attribute. Developers provide the name
attribute for a window that is different from its title. In the following example, a user can open a window by clicking on the Help button. In this case, the developer has ...
Get Selenium Testing Tools Cookbook - Second Edition 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.