I have the following code ...
# instantiate web driver
profile = webdriver.FirefoxProfile("C:\\Users\\me\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\me.default")
driver = webdriver.Firefox(firefox_profile=profile)
driver.wait = WebDriverWait(driver, 5)
# browse to bot detection page
driver.get("https://botometer.iuni.iu.edu")
# click dropdown button on navbar
button = driver.wait.until(EC.presence_of_element_located((By.CLASS_NAME, "dropdown-toggle")))
button.click()
# click login link
login_link = driver.wait.until(EC.presence_of_element_located((By.LINK_TEXT, "Log In")))
login_link.click()
# switch to authorize window
new_window = driver.window_handles[1]
driver.switch_to.window(new_window)
# click authorize button
authorize_button = driver.wait.until(EC.presence_of_element_located((By.ID, "allow")))
authorize_button.click()
time.sleep(5)
... that does the following:
Unfortunately, after the first button is clicked, the new window never opens, and the program terminates with this error:
selenium.common.exceptions.NoSuchWindowException: Message: Browsing context has been discarded
It was working fine before today and I'm not sure what happened. Any ideas?
It has nothing to do with selenium
. I'm getting this in browser DevTools
when trying your scenario manually:
It's a website issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With