Skip to content

Instantly share code, notes, and snippets.

@ab9-er
Created December 1, 2015 10:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ab9-er/08c3ce7d2d5cdfa94bc7 to your computer and use it in GitHub Desktop.
Save ab9-er/08c3ce7d2d5cdfa94bc7 to your computer and use it in GitHub Desktop.
A very simple window switcher using Selenium Webdriver
def change_window(browser):
"""
Simple window switcher without the need of playing with ids.
@param browser: Current browser instance
"""
curr = browser.current_window_handle
all_handles = browser.window_handles
for handle in list(set([curr]) - set(all_handles)):
return browser.switch_to_window(handle)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment