'Selects the window matching locator and return previous window handle.
locator: any of name, title, url, window handle, excluded handle\'s list, or special words.
return: either current window handle before selecting, or None if no current window.
If the window is found, all subsequent commands use that window, until
this keyword is used again. If the window is not found, this keyword fails.
By default, when a locator value is provided,
it is matched against the title of the window and the
javascript name of the window. If multiple windows with
same identifier are found, the first one is selected.
There are some special locators for searching target window:
string \'main\' (default): select the main window;
string \'self\': only return current window handle;
string \'new\': select the last-indexed window assuming it is the newest opened window
window list: select the first window not in given list (See \'List Windows\' to get the list)
It is also possible to specify the approach Selenium2Library should take
to find a window by specifying a locator strategy:
| *Strategy* | *Example*                               | *Description*                        |
| title      | Select Window `|` title=My Document     | Matches by window title              |
| name       | Select Window `|` name=${name}          | Matches by window javascript name    |
| url        | Select Window `|` url=http://google.com | Matches by window\'s current URL      |
Example:
| Click Link | popup_link | # opens new window |
| Select Window | popupName |
| Title Should Be | Popup Title |
| Select Window |  | | # Chooses the main window again |'

@keyword
def select_window(self, locator=None):

    try:
        return self.browser.current_window_handle
    except NoSuchWindowException:
        pass
    finally:
        self._window_manager.select(self.browser, locator)
