How Does Python Handle New Windows in Selenium?

Timothy Joseph Timothy Joseph | November 22, 2021

How Does Python Handle New Windows in Selenium?

Enterprise applications have long end-to-end scenarios where we need to pass the result of a few steps to the next scenario while execution continues in another window.

So, we have to handle multiple windows as per the requirement of the test case/script. During execution, we need to go back to the previous window or move to the next window.

Selenium webdriver provides modules that can use methods to access the previous or next window.

Save handle i.e 1st_window= driver.window_handles[0]
If you want to switch to another window driver.switch_to_window(driver.window_handles[1]);
If you want to Switch to 1st window then execute driver.switch_to.window(1st_window)
To close the window execute driver.close()

For more information and assistance, schedule a call with our team of experienced QA engineers today.

Contact Us


This publication is for informational purposes only and nothing contained in it should be considered legal advice. We expressly disclaim any warranty or responsibility for damages arising out of this information and encourage you to consult with legal counsel regarding your specific needs. We do not undertake any duty to update previously posted materials.

Post a Comment