Skip to content

Commit fa200c0

Browse files
committed
Add Expected Conditions example for Python
1 parent ea51639 commit fa200c0

File tree

5 files changed

+31
-17
lines changed

5 files changed

+31
-17
lines changed
Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,20 @@
1-
from selenium import webdriver
1+
import pytest
22

3+
from selenium.webdriver.common.by import By
4+
from selenium.webdriver.support import expected_conditions as EC
5+
from selenium.webdriver.support.wait import WebDriverWait
6+
7+
# Expected Conditions API Documentation:
8+
# https://www.selenium.dev/selenium/docs/api/py/webdriver_support/selenium.webdriver.support.expected_conditions.html
9+
10+
11+
def test_expected_condition(driver):
12+
driver.get("https://www.selenium.dev/selenium/web/dynamic.html")
13+
revealed = driver.find_element(By.ID, "revealed")
14+
driver.find_element(By.ID, "reveal").click()
15+
16+
wait = WebDriverWait(driver, timeout=2)
17+
wait.until(EC.visibility_of_element_located((By.ID, "revealed")))
18+
19+
revealed.send_keys("Displayed")
20+
assert revealed.get_property("value") == "Displayed"

website_and_docs/content/documentation/webdriver/support_features/expected_conditions.en.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ These methods can include conditions such as:
2424
[Expected Conditions Documentation](https://www.selenium.dev/selenium/docs/api/java/org/openqa/selenium/support/ui/ExpectedConditions.html)
2525
{{< badge-code >}}
2626
{{% /tab %}}
27-
{{< tab header="Python" >}}
28-
[Expected Conditions Documentation](https://www.selenium.dev/selenium/docs/api/py/webdriver_support/selenium.webdriver.support.expected_conditions.html)
29-
{{< badge-code >}}
30-
{{< /tab >}}
27+
{{% tab header="Python" %}}
28+
{{< gh-codeblock path="examples/python/tests/support/test_expected_conditions.py#L16-L17" >}}
29+
{{% /tab %}}
3130
{{< tab header="CSharp" >}}
3231
.NET stopped supporting Expected Conditions in Selenium 4 to minimize maintenance hassle and redundancy.
3332
{{< /tab >}}

website_and_docs/content/documentation/webdriver/support_features/expected_conditions.ja.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ These methods can include conditions such as:
2424
[Expected Conditions Documentation](https://www.selenium.dev/selenium/docs/api/java/org/openqa/selenium/support/ui/ExpectedConditions.html)
2525
{{< badge-code >}}
2626
{{% /tab %}}
27-
{{< tab header="Python" >}}
28-
[Expected Conditions Documentation](https://www.selenium.dev/selenium/docs/api/py/webdriver_support/selenium.webdriver.support.expected_conditions.html)
29-
{{< badge-code >}}
30-
{{< /tab >}}
27+
{{% tab header="Python" %}}
28+
{{< gh-codeblock path="examples/python/tests/support/test_expected_conditions.py#L16-L17" >}}
29+
{{% /tab %}}
3130
{{< tab header="CSharp" >}}
3231
.NET stopped supporting Expected Conditions in Selenium 4 to minimize maintenance hassle and redundancy.
3332
{{< /tab >}}

website_and_docs/content/documentation/webdriver/support_features/expected_conditions.pt-br.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ These methods can include conditions such as:
2424
[Expected Conditions Documentation](https://www.selenium.dev/selenium/docs/api/java/org/openqa/selenium/support/ui/ExpectedConditions.html)
2525
{{< badge-code >}}
2626
{{% /tab %}}
27-
{{< tab header="Python" >}}
28-
[Expected Conditions Documentation](https://www.selenium.dev/selenium/docs/api/py/webdriver_support/selenium.webdriver.support.expected_conditions.html)
29-
{{< badge-code >}}
30-
{{< /tab >}}
27+
{{% tab header="Python" %}}
28+
{{< gh-codeblock path="examples/python/tests/support/test_expected_conditions.py#L16-L17" >}}
29+
{{% /tab %}}
3130
{{< tab header="CSharp" >}}
3231
.NET stopped supporting Expected Conditions in Selenium 4 to minimize maintenance hassle and redundancy.
3332
{{< /tab >}}

website_and_docs/content/documentation/webdriver/support_features/expected_conditions.zh-cn.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ description: >
2424
[Expected Conditions Documentation](https://www.selenium.dev/selenium/docs/api/java/org/openqa/selenium/support/ui/ExpectedConditions.html)
2525
{{< badge-code >}}
2626
{{% /tab %}}
27-
{{< tab header="Python" >}}
28-
[Expected Conditions Documentation](https://www.selenium.dev/selenium/docs/api/py/webdriver_support/selenium.webdriver.support.expected_conditions.html)
29-
{{< badge-code >}}
30-
{{< /tab >}}
27+
{{% tab header="Python" %}}
28+
{{< gh-codeblock path="examples/python/tests/support/test_expected_conditions.py#L16-L17" >}}
29+
{{% /tab %}}
3130
{{< tab header="CSharp" >}}
3231
.NET stopped supporting Expected Conditions in Selenium 4 to minimize maintenance hassle and redundancy.
3332
{{< /tab >}}

0 commit comments

Comments
 (0)