Does getWindowHandles() method return handles in the same order as windows launch?

As part of the Selenium WebDriver – Java series, let’s learn how does getWindowHandles() work.

If multiple child windows are launched in an application due to some actions then Selenium WebDriver provides the capability to handle multiple windows. We can switch to any open window and perform actions. Selenium provides a method getWindowHandles() to get handles of all open windows. Do getWindowHandles() method return the window handles in the same order it was launched? Let’s find the answer by executing sample programs.

I have used the below dependency of Selenium WebDriver – Java.

  org.seleniumhq.selenium selenium-java 3.141.59

I have created a webpage that opens “Google”, “Facebook” and “Flipkart” websites in a new tab.

You can find the HTML code below:-


multiopen