def switch_to_new_window(self):
sleep(5)
print("Parent window title: " + self.webdriver.title)
parentWindow = self.webdriver.current_window_handle
childWindows = self.webdriver.window_handles
for window in childWindows:
if(window!=parentWindow):
self.webdriver.switch_to.window(window)
break
sleep(2)
print("Child window title: " + self.webdriver.title)
The above works for other popup windows but not for gmail popup window. The gmail popup window doesn't have a close button. Gmail popup