Continuous Test Orchestration And Execution Platform Online

Perform automated and live-interactive testing on 3000+ real desktop and mobile devices online.

How to make another window in Selenium?

In Selenium, you can create a new window by using the "window_handles" attribute, which returns the handles of all currently open windows. Then, using the “switch to.window()” method, you may go to the chosen window.

What is the window_handles attribute?

When you open a new browser window or tab, Selenium generates a new window handle for that window. The window handles attribute allows you to access and switch between these handles.

Here are different use cases of the window_handles attribute in Python:

  • Moving between windows: You can acquire a list of all open window handles by using the window_handles attribute and then use the switch to.window() method to switch between them.
  • Closing windows: Use the window handles attribute to acquire a list of all open window handles, and then use the close() method to close a specific window.
  • Opening new windows: The execute_script() method can open a new window, and the window handles attribute can be used to receive a list of all open window handles, including the newly launched window.
  • Counting the number of open windows: The length of the list supplied by the window handles attribute can be used to calculate the number of open windows using the len() function.

Test your websites, web-apps, or mobile apps seamlessly with LambdaTest.

Start Free Testing

Earn resume-worthy Selenium certifications that help you land a top job.

Learn More

Test your web or mobile apps

Test orchestration and execution cloud of 3000+ browsers and OS


24/7 support


Enterprise grade security


Fastest test execution cloud