Closed paulotcj closed 2 months ago
@paulotcj, thank you for creating this issue. We will troubleshoot it as soon as we can.
Triage this issue by using labels.
If information is missing, add a helpful comment and then I-issue-template
label.
If the issue is a question, add the I-question
label.
If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted
label.
After troubleshooting the issue, please add the R-awaiting answer
label.
Thank you!
Hmm, I think the expected condition does switch to the alert?
At any rate, we are trying to update all code examples to actual code in the examples directory of this repo so that we can ensure things are properly passing. (https://www.selenium.dev/documentation/about/style/#reference-github-examples)
Is there any chance you'd be interested in writing that code in: https://github.com/SeleniumHQ/seleniumhq.github.io/tree/trunk/examples/python/tests/interactions/test_alerts.py so that we can see it passing? We want all code examples using code in selenium.dev, so alerts tests should use: https://www.selenium.dev/selenium/web/alerts.html
Hi @paulotcj , @titusfortner , This issue will mostly be covered by https://github.com/SeleniumHQ/seleniumhq.github.io/pull/1470
Can be closed. Current python code example is as follows:
element = driver.find_element(By.LINK_TEXT, "See an example alert")
element.click()
wait = WebDriverWait(driver, timeout=2)
alert = wait.until(lambda d : d.switch_to.alert)
text = alert.text
alert.accept()
Thank you, @shbenzer!
What happened?
In the documentation, the first example for handling alerts in Python at the address: https://www.selenium.dev/documentation/webdriver/interactions/alerts/ is the following:
`driver.find_element(By.LINK_TEXT, "See an example alert").click()
alert = wait.until(expected_conditions.alert_is_present())
text = alert.text alert.accept()`
However, this code will fail. The probable solution as the example below hints, should be: `driver.find_element(By.LINK_TEXT, "See an example alert").click()
WebDriverWait(driver, 10).until(expected_conditions.alert_is_present())
alert = driver.switch_to.alert
alert.accept()`
My apologies if I am missing something here.
What browsers and operating systems are you seeing the problem on?
Any