public void selectWindowByTitle(final String title) {
		String currentWindow = driver.getWindowHandle();
		Set<String> handles = driver.getWindowHandles();
		if (!handles.isEmpty()) {
			for (String windowId : handles) {
				if (!driver.switchTo().window(windowId).getTitle()
						.equals(title)) {
					driver.switchTo().window(currentWindow);
				}
			}
		}
	}
public void selectWindowByTitle ( final String title ) { String currentWindow = driver . getWindowHandle ( ) ; Set < String > handles = driver . getWindowHandles ( ) ; if ( ! handles . isEmpty ( ) ) { for ( String windowId : handles ) { if ( ! driver . switchTo ( ) . window ( windowId ) . getTitle ( ) . equals ( title ) ) { driver . switchTo ( ) . window ( currentWindow ) ; } } } }
Used to switch to a window by title.

@param title
the title of the window to switch to