Skip to content

Add Expected Conditions example for Python #2286

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

Merged
merged 3 commits into from
Apr 26, 2025
Merged
Show file tree
Hide file tree
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: 17 additions & 1 deletion examples/python/tests/support/test_expected_conditions.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
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

# 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"
Original file line number Diff line number Diff line change
Expand Up @@ -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#L14-L15" >}}
{{% /tab %}}
{{< tab header="CSharp" >}}
.NET stopped supporting Expected Conditions in Selenium 4 to minimize maintenance hassle and redundancy.
{{< /tab >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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#L14-L15" >}}
{{% /tab %}}
{{< tab header="CSharp" >}}
.NET stopped supporting Expected Conditions in Selenium 4 to minimize maintenance hassle and redundancy.
{{< /tab >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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#L14-L15" >}}
{{% /tab %}}
{{< tab header="CSharp" >}}
.NET stopped supporting Expected Conditions in Selenium 4 to minimize maintenance hassle and redundancy.
{{< /tab >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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#L14-L15" >}}
{{% /tab %}}
{{< tab header="CSharp" >}}
.NET stopped supporting Expected Conditions in Selenium 4 to minimize maintenance hassle and redundancy.
{{< /tab >}}
Expand Down
Loading