-2

Picture: there is Popup window in the html

    try:
        all_handles = self.driver.window_handles
        for handle in all_handles:
            if handle != now_handle:
                print handle
                try:
                    self.driver.switch_to_window(handle)
                    self.driver.find_element_by_xpath(".//*[@id='ks-overlay-close-ks-component9045']").click()
                except:
                    continue

but it is failed, i can not switch to the window and close it

flora
  • 1
  • 1

1 Answers1

0

This one does not look like a browser pop up window. In this case you don't need switch_to_window and window_handles functions, just find the DOM element that represents the close button and have click on it.

Shijo
  • 9,313
  • 3
  • 19
  • 31