I am currently facing a challenge while attempting to automate the handling of an alert generated by a specific link using Selenium WebDriver. Upon clicking the link, an alert pops up, but my WebDriver is encountering difficulties in switching to this alert. I have attempted to diagnose the issue by capturing the page source and taking a screenshot for analysis using the following code snippets:
enter image description here[enter image description here][1]This is what the site look likeenter image description here
Code:
driver = webdriver.Chrome()
driver.get(" ")
time.sleep(3)
print(driver.page_source)
driver.save_screenshot("screenshot.png")
alert = WebDriverWait(driver, 10).until(EC.alert_is_present())
alert.send_keys(" ")
alert.send_keys(Keys.TAB) # Move to the password field
alert.send_keys(" ")
alert.accept()`
the WebDriver is reporting an error stating, "No Alert Found," signifying its inability to switch to the alert
This is generic Authentication popup. To bypass it, you can pass your credentials inside url
def authenticate(driver, login, password, url):
driver.get(f"https://{login}:{password}@{url}")
authenticate(driver, 'admin','admin','the-internet.herokuapp.com/basic_auth')