diff --git a/examples/python/tests/interactions/test_alerts.py b/examples/python/tests/interactions/test_alerts.py index 59b2cb15698c..067c21c41941 100644 --- a/examples/python/tests/interactions/test_alerts.py +++ b/examples/python/tests/interactions/test_alerts.py @@ -1,6 +1,7 @@ from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait +from selenium.webdriver.support import expected_conditions as EC global url url = "https://www.selenium.dev/documentation/webdriver/interactions/alerts/" @@ -13,11 +14,11 @@ def test_alert_popup(): element.click() wait = WebDriverWait(driver, timeout=2) - alert = wait.until(lambda d : d.switch_to.alert) + alert = wait.until(EC.alert_is_present()) text = alert.text alert.accept() assert text == "Sample alert" - + driver.quit() def test_confirm_popup(): @@ -27,7 +28,7 @@ def test_confirm_popup(): driver.execute_script("arguments[0].click();", element) wait = WebDriverWait(driver, timeout=2) - alert = wait.until(lambda d : d.switch_to.alert) + alert = wait.until(EC.alert_is_present()) text = alert.text alert.dismiss() assert text == "Are you sure?" @@ -41,7 +42,7 @@ def test_prompt_popup(): driver.execute_script("arguments[0].click();", element) wait = WebDriverWait(driver, timeout=2) - alert = wait.until(lambda d : d.switch_to.alert) + alert = wait.until(EC.alert_is_present()) alert.send_keys("Selenium") text = alert.text alert.accept() diff --git a/website_and_docs/content/documentation/webdriver/interactions/alerts.en.md b/website_and_docs/content/documentation/webdriver/interactions/alerts.en.md index 432946b674af..252854279774 100644 --- a/website_and_docs/content/documentation/webdriver/interactions/alerts.en.md +++ b/website_and_docs/content/documentation/webdriver/interactions/alerts.en.md @@ -30,7 +30,7 @@ alerts. {{< /tab >}} {{< tab header="Python" text=true >}} -{{< gh-codeblock path="/examples/python/tests/interactions/test_alerts.py#L12-L18" >}} +{{< gh-codeblock path="/examples/python/tests/interactions/test_alerts.py#L12-L20" >}} {{< /tab >}} {{< tab header="CSharp" >}} @@ -81,7 +81,7 @@ This example also shows a different approach to storing an alert: {{< /tab >}} {{< tab header="Python" text=true >}} -{{< gh-codeblock path="/examples/python/tests/interactions/test_alerts.py#L26-L32" >}} +{{< gh-codeblock path="/examples/python/tests/interactions/test_alerts.py#L26-L34" >}} {{< /tab >}} {{< tab header="CSharp" >}} @@ -140,7 +140,7 @@ See a sample prompt. {{< /tab >}} {{< tab header="Python" text=true >}} -{{< gh-codeblock path="/examples/python/tests/interactions/test_alerts.py#L40-L47" >}} +{{< gh-codeblock path="/examples/python/tests/interactions/test_alerts.py#L40-L49" >}} {{< /tab >}} {{< tab header="CSharp" >}} diff --git a/website_and_docs/content/documentation/webdriver/interactions/alerts.ja.md b/website_and_docs/content/documentation/webdriver/interactions/alerts.ja.md index 1e5d9716351f..ce13b7587a9b 100644 --- a/website_and_docs/content/documentation/webdriver/interactions/alerts.ja.md +++ b/website_and_docs/content/documentation/webdriver/interactions/alerts.ja.md @@ -26,7 +26,7 @@ WebDriverはポップアップからテキストを取得し、これらのア {{< /tab >}} {{< tab header="Python" text=true >}} -{{< gh-codeblock path="/examples/python/tests/interactions/test_alerts.py#L12-L18" >}} +{{< gh-codeblock path="/examples/python/tests/interactions/test_alerts.py#L12-L20" >}} {{< /tab >}} {{< tab header="CSharp" >}} @@ -76,7 +76,7 @@ alert.accept() {{< /tab >}} {{< tab header="Python" text=true >}} -{{< gh-codeblock path="/examples/python/tests/interactions/test_alerts.py#L26-L32" >}} +{{< gh-codeblock path="/examples/python/tests/interactions/test_alerts.py#L26-L34" >}} {{< /tab >}} {{< tab header="CSharp" >}} @@ -133,7 +133,7 @@ alert.dismiss() {{< /tab >}} {{< tab header="Python" text=true >}} -{{< gh-codeblock path="/examples/python/tests/interactions/test_alerts.py#L40-L47" >}} +{{< gh-codeblock path="/examples/python/tests/interactions/test_alerts.py#L40-L49" >}} {{< /tab >}} {{< tab header="CSharp" >}} diff --git a/website_and_docs/content/documentation/webdriver/interactions/alerts.pt-br.md b/website_and_docs/content/documentation/webdriver/interactions/alerts.pt-br.md index aadb4a30575b..7d5d8167dd54 100644 --- a/website_and_docs/content/documentation/webdriver/interactions/alerts.pt-br.md +++ b/website_and_docs/content/documentation/webdriver/interactions/alerts.pt-br.md @@ -29,7 +29,7 @@ alertas. {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/interactions/AlertsTest.java#L36-L41" >}} {{< /tab >}} {{< tab header="Python" text=true >}} -{{< gh-codeblock path="/examples/python/tests/interactions/test_alerts.py#L12-L18" >}} +{{< gh-codeblock path="/examples/python/tests/interactions/test_alerts.py#L12-L20" >}} {{< /tab >}} {{< tab header="Ruby" text=true >}} @@ -67,7 +67,7 @@ Este exemplo também mostra uma abordagem diferente para armazenar um alerta: {{< /tab >}} {{< tab header="Python" text=true >}} -{{< gh-codeblock path="/examples/python/tests/interactions/test_alerts.py#L26-L32" >}} +{{< gh-codeblock path="/examples/python/tests/interactions/test_alerts.py#L26-L34" >}} {{< /tab >}} {{< tab header="CSharp" >}} @@ -126,7 +126,7 @@ Veja um exemplo de prompt . {{< /tab >}} {{< tab header="Python" text=true >}} -{{< gh-codeblock path="/examples/python/tests/interactions/test_alerts.py#L40-L47" >}} +{{< gh-codeblock path="/examples/python/tests/interactions/test_alerts.py#L40-L49" >}} {{< /tab >}} {{< tab header="CSharp" >}} diff --git a/website_and_docs/content/documentation/webdriver/interactions/alerts.zh-cn.md b/website_and_docs/content/documentation/webdriver/interactions/alerts.zh-cn.md index a59b74bebf9c..03711b375431 100644 --- a/website_and_docs/content/documentation/webdriver/interactions/alerts.zh-cn.md +++ b/website_and_docs/content/documentation/webdriver/interactions/alerts.zh-cn.md @@ -23,7 +23,7 @@ WebDriver可以从弹窗获取文本并接受或关闭这些警告. {{< /tab >}} {{< tab header="Python" text=true >}} -{{< gh-codeblock path="/examples/python/tests/interactions/test_alerts.py#L12-L18" >}} +{{< gh-codeblock path="/examples/python/tests/interactions/test_alerts.py#L12-L20" >}} {{< /tab >}} {{< tab header="CSharp" >}} @@ -72,7 +72,7 @@ alert.accept() {{< /tab >}} {{< tab header="Python" text=true >}} -{{< gh-codeblock path="/examples/python/tests/interactions/test_alerts.py#L26-L32" >}} +{{< gh-codeblock path="/examples/python/tests/interactions/test_alerts.py#L26-L34" >}} {{< /tab >}} {{< tab header="CSharp" >}} @@ -128,7 +128,7 @@ alert.dismiss() {{< /tab >}} {{< tab header="Python" text=true >}} -{{< gh-codeblock path="/examples/python/tests/interactions/test_alerts.py#L40-L47" >}} +{{< gh-codeblock path="/examples/python/tests/interactions/test_alerts.py#L40-L49" >}} {{< /tab >}} {{< tab header="CSharp" >}}