Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 98893

AttributeError: module 'selenium.webdriver' has no attribute 'switch_to_alert'

$
0
0

I am making a simple crawler that can open a site and when a pop up appears, it should close it. but the following command isn't working.

from selenium import webdriver

browser = webdriver.Chrome(executable_path=r"C:\Program Files\chromedriver.exe")
url = "https://www.bnbaccessories.com/"
browser.get(url)

alert = webdriver.switch_to_alert().dismiss()

innerHTML = browser.execute_script("return document.body.innerHTML")
browser.implicitly_wait(50)
browser.close()

Viewing all articles
Browse latest Browse all 98893

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>