Hack Forums
SELENIUM WEBDRIVER SWITCH POPUP - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Hacks, Exploits, and Various Discussions (https://hackforums.net/forumdisplay.php?fid=45)
+--- Forum: Blackhat • Red Team • Offensive Security (https://hackforums.net/forumdisplay.php?fid=447)
+---- Forum: Hacking Tools and Programs (https://hackforums.net/forumdisplay.php?fid=10)
+---- Thread: SELENIUM WEBDRIVER SWITCH POPUP (/showthread.php?tid=6059118)



SELENIUM WEBDRIVER SWITCH POPUP - ekipa - Mar 22, 2020

HEY, I need a code that will change from the main window to the POPUP window (below adds a picture of the POPUP window), then do one action, and
closes the POPUP window and returns to the main window.
Thank you in advance for any help!!
CODE:
Code
driver.find_element_by_xpath('//*[@id="login"]/fieldset/table/tbody/tr[8]/td/a').click()
sleep(20)

driver.find_element_by_xpath('/html/body/div[6]/div[2]/div[2]/div[1]/div/div/table/tbody/tr[5]/td[1]/div/div[2]/div/span/a').click()
sleep(7)

driver.switch_to().window(driver.windowhandles.toList().last())
sleep(3)

driver.find_element_by_xpath('//*[@id="react-root"]/section/main/div/header/section/div[1]/a/button').click()
driver.switch_to().window(driver.windowhandles.toList().first())
driver.SwitchTo().DefaultContent();
WINDOW POPUP:
https ://imgur.com/qTnXahN (without space after https)r