What are the different methods used for window handling in Selenium?

What are the different methods used for window handling in Selenium?

Hey Aaron,

Selenium provides a few important methods that can help you in performing Window handling. These methods are:

  • driver.getWindowHandle() - Returns the handler for current window.

  • driver.getWindowHandles() - Returns the handler for all opened windows.

  • driver.switchTo().window() - This method helps to switch over from one window to another, with the help of window handle.

  • driver.close() - Close the current browser window.

  • driver.quit() - Close all opened browser windows and exits the driver instance used by the script that invokes it.

You can go through the following blog to deep dive into each of these methods:

2 Likes