I\'m new to Selenium learning. WebDriver.getWindowHandle() documentation is not very clear to me and the example is not working as given in the book, so I thought of confirm
getWindowHandle()
will get the handle of the page the webDriver is currently controlling. This handle is a unique identifier for the web page. This is different every time you open a page even if it is the same URL.
getWindowHandles()
(don't forget the 's') will give you all the handles for all the pages that the web driver understands are open. Note that when you put these in a list they are listed in the order that they have been opened.
You can use SwitchTo().Window("handle")
to switch to the window you desire.
You can use SwitchTo().Window("mywindowID")
, if you know the window ID.
SwitchTo().Window("")
will always go back to the base/main window.
SwitchTo().Frame("popupFrame")
will get to the Popup that came from the window the webdriver is currently controlling.