Skip to content

Commit 46c35d6

Browse files
authored
Add Expected Conditions example for Python (#2286)[deploy site]
* Add Expected Conditions example for Python * Remove import and adjust line numbers
1 parent b198d3c commit 46c35d6

File tree

5 files changed

+29
-17
lines changed

5 files changed

+29
-17
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,18 @@
1-
from selenium import webdriver
1+
from selenium.webdriver.common.by import By
2+
from selenium.webdriver.support import expected_conditions as EC
3+
from selenium.webdriver.support.wait import WebDriverWait
24

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

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

+3-4
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#L14-L15" >}}
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

+3-4
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#L14-L15" >}}
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

+3-4
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#L14-L15" >}}
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

+3-4
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#L14-L15" >}}
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)