-1

I am doing automated testing using Selenium WebDriver with Python In Internet Explorer. I have opened multiple windows in IE 11 and I closed the current window, after that second last opened window is not getting any focus so to give focus to second last window I want to click and hold on ALT button and then click on ESC button so that second last window get focus.

Basically, I need to achieve the focus on second last window.

eg: SendKeys.SendKeys("{ALT}" + "{ESC}")

Please help me. Thanks in advance.

  • Possible duplicate of [Python Selenium: How to send ESC key to close pop up window?](https://stackoverflow.com/questions/41649916/python-selenium-how-to-send-esc-key-to-close-pop-up-window) – JeffC Sep 07 '17 at 13:33

1 Answers1

1

ActionChains is what you're looking for.

from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys

combine_keys = ActionChains(driver)
combine_keys.key_down(Keys.ALT).send_keys(Keys.ESCAPE).key_up(Keys.ALT).perform()
leeand00
  • 25,510
  • 39
  • 140
  • 297
JJAACCEeEKK
  • 194
  • 1
  • 11