-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Selenium Testing Tools Cookbook Second Edition
By :
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 provided HelpWindow as its name:
<button id="helpbutton" onClick='window.open("help.html","HelpWindow","width=500,height=500");'>Help</button>Let's create a test that identifies a window using its name attribute, as shown...
Change the font size
Change margin width
Change background colour