Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for #1333 | Python alert automation #1470

Open
wants to merge 8 commits into
base: trunk
Choose a base branch
from
30 changes: 30 additions & 0 deletions examples/python/tests/interactions/test_alerts.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,32 @@
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.alert import Alert
from selenium.webdriver.support import expected_conditions

driver = webdriver.Chrome()
wait = WebDriverWait(driver, timeout=2)

driver.get("https://www.selenium.dev/selenium/web/alerts.html")

driver.find_element(By.ID, "alert").click()
alert = wait.until(expected_conditions.alert_is_present())
text = alert.text
alert.accept()


driver.find_element(By.LINK_TEXT, "test confirm").click()
wait.until(expected_conditions.alert_is_present())
alert = driver.switch_to.alert
text = alert.text
alert.dismiss()


driver.find_element(By.ID, "prompt").click()
wait.until(expected_conditions.alert_is_present())
alert = Alert(driver)
alert.send_keys("Selenium")
alert.accept()


driver.quit()