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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update test_alerts.py #1524

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions examples/python/tests/interactions/test_alerts.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,20 @@
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait


driver = webdriver.Chrome()
driver.get('https://www.selenium.dev/zh-cn/documentation/webdriver/interactions/alerts/')
print(driver.page_source)

alert_dialog = driver.find_element(by=By.LINK_TEXT,value=""See an example alert"")
alert_dialog.click()
# Wait for the alert to be displayed and store it in a variable
alert = WebDriverWait(driver,10).until(EC.alert_is_present())

print(alert.text)
# Press the OK button
alert.accept()

driver.quit()