public void switchToNewWindow ( ) { String action = "Switching to the new window" ; String expected = "New window is available and selected" ; try { parentWindow = driver . getWindowHandle ( ) ; for ( String winHandle : driver . getWindowHandles ( ) ) { driver . switchTo ( ) . window ( winHandle ) ; } } catch ( Exception e ) { reporter . fail ( action , expected , "New window was unable to be selected. " + e . getMessage ( ) ) ; log . warn ( e ) ; return ; } reporter . pass ( action , expected , expected ) ; }
Switches to the next window . This is an alternative to switchNextTab or switchPreviousTab as this works better for some systems and environments that others .