From fa200c0cc0c427d77dcfaa117abf6bdd6a187caa Mon Sep 17 00:00:00 2001 From: Corey Goldberg <1113081+cgoldberg@users.noreply.github.com> Date: Wed, 23 Apr 2025 22:10:28 -0400 Subject: [PATCH 1/2] Add Expected Conditions example for Python --- .../tests/support/test_expected_conditions.py | 20 ++++++++++++++++++- .../expected_conditions.en.md | 7 +++---- .../expected_conditions.ja.md | 7 +++---- .../expected_conditions.pt-br.md | 7 +++---- .../expected_conditions.zh-cn.md | 7 +++---- 5 files changed, 31 insertions(+), 17 deletions(-) diff --git a/examples/python/tests/support/test_expected_conditions.py b/examples/python/tests/support/test_expected_conditions.py index 53b695b6fc83..3cdbf631bd6f 100644 --- a/examples/python/tests/support/test_expected_conditions.py +++ b/examples/python/tests/support/test_expected_conditions.py @@ -1,2 +1,20 @@ -from selenium import webdriver +import pytest +from selenium.webdriver.common.by import By +from selenium.webdriver.support import expected_conditions as EC +from selenium.webdriver.support.wait import WebDriverWait + +# Expected Conditions API Documentation: +# https://www.selenium.dev/selenium/docs/api/py/webdriver_support/selenium.webdriver.support.expected_conditions.html + + +def test_expected_condition(driver): + driver.get("https://www.selenium.dev/selenium/web/dynamic.html") + revealed = driver.find_element(By.ID, "revealed") + driver.find_element(By.ID, "reveal").click() + + wait = WebDriverWait(driver, timeout=2) + wait.until(EC.visibility_of_element_located((By.ID, "revealed"))) + + revealed.send_keys("Displayed") + assert revealed.get_property("value") == "Displayed" diff --git a/website_and_docs/content/documentation/webdriver/support_features/expected_conditions.en.md b/website_and_docs/content/documentation/webdriver/support_features/expected_conditions.en.md index 729ccb3908a1..a62993e0ccc8 100644 --- a/website_and_docs/content/documentation/webdriver/support_features/expected_conditions.en.md +++ b/website_and_docs/content/documentation/webdriver/support_features/expected_conditions.en.md @@ -24,10 +24,9 @@ These methods can include conditions such as: [Expected Conditions Documentation](https://www.selenium.dev/selenium/docs/api/java/org/openqa/selenium/support/ui/ExpectedConditions.html) {{< badge-code >}} {{% /tab %}} -{{< tab header="Python" >}} -[Expected Conditions Documentation](https://www.selenium.dev/selenium/docs/api/py/webdriver_support/selenium.webdriver.support.expected_conditions.html) -{{< badge-code >}} -{{< /tab >}} +{{% tab header="Python" %}} +{{< gh-codeblock path="examples/python/tests/support/test_expected_conditions.py#L16-L17" >}} +{{% /tab %}} {{< tab header="CSharp" >}} .NET stopped supporting Expected Conditions in Selenium 4 to minimize maintenance hassle and redundancy. {{< /tab >}} diff --git a/website_and_docs/content/documentation/webdriver/support_features/expected_conditions.ja.md b/website_and_docs/content/documentation/webdriver/support_features/expected_conditions.ja.md index 729ccb3908a1..a62993e0ccc8 100644 --- a/website_and_docs/content/documentation/webdriver/support_features/expected_conditions.ja.md +++ b/website_and_docs/content/documentation/webdriver/support_features/expected_conditions.ja.md @@ -24,10 +24,9 @@ These methods can include conditions such as: [Expected Conditions Documentation](https://www.selenium.dev/selenium/docs/api/java/org/openqa/selenium/support/ui/ExpectedConditions.html) {{< badge-code >}} {{% /tab %}} -{{< tab header="Python" >}} -[Expected Conditions Documentation](https://www.selenium.dev/selenium/docs/api/py/webdriver_support/selenium.webdriver.support.expected_conditions.html) -{{< badge-code >}} -{{< /tab >}} +{{% tab header="Python" %}} +{{< gh-codeblock path="examples/python/tests/support/test_expected_conditions.py#L16-L17" >}} +{{% /tab %}} {{< tab header="CSharp" >}} .NET stopped supporting Expected Conditions in Selenium 4 to minimize maintenance hassle and redundancy. {{< /tab >}} diff --git a/website_and_docs/content/documentation/webdriver/support_features/expected_conditions.pt-br.md b/website_and_docs/content/documentation/webdriver/support_features/expected_conditions.pt-br.md index 298cbe838688..09fd6e699657 100644 --- a/website_and_docs/content/documentation/webdriver/support_features/expected_conditions.pt-br.md +++ b/website_and_docs/content/documentation/webdriver/support_features/expected_conditions.pt-br.md @@ -24,10 +24,9 @@ These methods can include conditions such as: [Expected Conditions Documentation](https://www.selenium.dev/selenium/docs/api/java/org/openqa/selenium/support/ui/ExpectedConditions.html) {{< badge-code >}} {{% /tab %}} -{{< tab header="Python" >}} -[Expected Conditions Documentation](https://www.selenium.dev/selenium/docs/api/py/webdriver_support/selenium.webdriver.support.expected_conditions.html) -{{< badge-code >}} -{{< /tab >}} +{{% tab header="Python" %}} +{{< gh-codeblock path="examples/python/tests/support/test_expected_conditions.py#L16-L17" >}} +{{% /tab %}} {{< tab header="CSharp" >}} .NET stopped supporting Expected Conditions in Selenium 4 to minimize maintenance hassle and redundancy. {{< /tab >}} diff --git a/website_and_docs/content/documentation/webdriver/support_features/expected_conditions.zh-cn.md b/website_and_docs/content/documentation/webdriver/support_features/expected_conditions.zh-cn.md index f9ce68fb0c46..b6428b3c91d6 100644 --- a/website_and_docs/content/documentation/webdriver/support_features/expected_conditions.zh-cn.md +++ b/website_and_docs/content/documentation/webdriver/support_features/expected_conditions.zh-cn.md @@ -24,10 +24,9 @@ description: > [Expected Conditions Documentation](https://www.selenium.dev/selenium/docs/api/java/org/openqa/selenium/support/ui/ExpectedConditions.html) {{< badge-code >}} {{% /tab %}} -{{< tab header="Python" >}} -[Expected Conditions Documentation](https://www.selenium.dev/selenium/docs/api/py/webdriver_support/selenium.webdriver.support.expected_conditions.html) -{{< badge-code >}} -{{< /tab >}} +{{% tab header="Python" %}} +{{< gh-codeblock path="examples/python/tests/support/test_expected_conditions.py#L16-L17" >}} +{{% /tab %}} {{< tab header="CSharp" >}} .NET stopped supporting Expected Conditions in Selenium 4 to minimize maintenance hassle and redundancy. {{< /tab >}} From 9edbb635950ba9b9d3325e5801f3643eb41b19f4 Mon Sep 17 00:00:00 2001 From: Corey Goldberg <1113081+cgoldberg@users.noreply.github.com> Date: Wed, 23 Apr 2025 22:16:26 -0400 Subject: [PATCH 2/2] Remove import and adjust line numbers --- examples/python/tests/support/test_expected_conditions.py | 2 -- .../webdriver/support_features/expected_conditions.en.md | 2 +- .../webdriver/support_features/expected_conditions.ja.md | 2 +- .../webdriver/support_features/expected_conditions.pt-br.md | 2 +- .../webdriver/support_features/expected_conditions.zh-cn.md | 2 +- 5 files changed, 4 insertions(+), 6 deletions(-) diff --git a/examples/python/tests/support/test_expected_conditions.py b/examples/python/tests/support/test_expected_conditions.py index 3cdbf631bd6f..fb93f26b79cd 100644 --- a/examples/python/tests/support/test_expected_conditions.py +++ b/examples/python/tests/support/test_expected_conditions.py @@ -1,5 +1,3 @@ -import pytest - from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.wait import WebDriverWait diff --git a/website_and_docs/content/documentation/webdriver/support_features/expected_conditions.en.md b/website_and_docs/content/documentation/webdriver/support_features/expected_conditions.en.md index a62993e0ccc8..ae8d70bcab8e 100644 --- a/website_and_docs/content/documentation/webdriver/support_features/expected_conditions.en.md +++ b/website_and_docs/content/documentation/webdriver/support_features/expected_conditions.en.md @@ -25,7 +25,7 @@ These methods can include conditions such as: {{< badge-code >}} {{% /tab %}} {{% tab header="Python" %}} -{{< gh-codeblock path="examples/python/tests/support/test_expected_conditions.py#L16-L17" >}} +{{< gh-codeblock path="examples/python/tests/support/test_expected_conditions.py#L14-L15" >}} {{% /tab %}} {{< tab header="CSharp" >}} .NET stopped supporting Expected Conditions in Selenium 4 to minimize maintenance hassle and redundancy. diff --git a/website_and_docs/content/documentation/webdriver/support_features/expected_conditions.ja.md b/website_and_docs/content/documentation/webdriver/support_features/expected_conditions.ja.md index a62993e0ccc8..ae8d70bcab8e 100644 --- a/website_and_docs/content/documentation/webdriver/support_features/expected_conditions.ja.md +++ b/website_and_docs/content/documentation/webdriver/support_features/expected_conditions.ja.md @@ -25,7 +25,7 @@ These methods can include conditions such as: {{< badge-code >}} {{% /tab %}} {{% tab header="Python" %}} -{{< gh-codeblock path="examples/python/tests/support/test_expected_conditions.py#L16-L17" >}} +{{< gh-codeblock path="examples/python/tests/support/test_expected_conditions.py#L14-L15" >}} {{% /tab %}} {{< tab header="CSharp" >}} .NET stopped supporting Expected Conditions in Selenium 4 to minimize maintenance hassle and redundancy. diff --git a/website_and_docs/content/documentation/webdriver/support_features/expected_conditions.pt-br.md b/website_and_docs/content/documentation/webdriver/support_features/expected_conditions.pt-br.md index 09fd6e699657..2c2a3f75d80b 100644 --- a/website_and_docs/content/documentation/webdriver/support_features/expected_conditions.pt-br.md +++ b/website_and_docs/content/documentation/webdriver/support_features/expected_conditions.pt-br.md @@ -25,7 +25,7 @@ These methods can include conditions such as: {{< badge-code >}} {{% /tab %}} {{% tab header="Python" %}} -{{< gh-codeblock path="examples/python/tests/support/test_expected_conditions.py#L16-L17" >}} +{{< gh-codeblock path="examples/python/tests/support/test_expected_conditions.py#L14-L15" >}} {{% /tab %}} {{< tab header="CSharp" >}} .NET stopped supporting Expected Conditions in Selenium 4 to minimize maintenance hassle and redundancy. diff --git a/website_and_docs/content/documentation/webdriver/support_features/expected_conditions.zh-cn.md b/website_and_docs/content/documentation/webdriver/support_features/expected_conditions.zh-cn.md index b6428b3c91d6..f25b9d5e5215 100644 --- a/website_and_docs/content/documentation/webdriver/support_features/expected_conditions.zh-cn.md +++ b/website_and_docs/content/documentation/webdriver/support_features/expected_conditions.zh-cn.md @@ -25,7 +25,7 @@ description: > {{< badge-code >}} {{% /tab %}} {{% tab header="Python" %}} -{{< gh-codeblock path="examples/python/tests/support/test_expected_conditions.py#L16-L17" >}} +{{< gh-codeblock path="examples/python/tests/support/test_expected_conditions.py#L14-L15" >}} {{% /tab %}} {{< tab header="CSharp" >}} .NET stopped supporting Expected Conditions in Selenium 4 to minimize maintenance hassle and redundancy.