Skip to content
Open
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
9 changes: 5 additions & 4 deletions examples/python/tests/interactions/test_alerts.py
Original file line number Diff line number Diff line change
@@ -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/"
Expand All @@ -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"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this whitespace.

driver.quit()

def test_confirm_popup():
Expand All @@ -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?"
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" >}}
Expand Down Expand Up @@ -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" >}}
Expand Down Expand Up @@ -140,7 +140,7 @@ See a sample prompt</a>.
{{< /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" >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" >}}
Expand Down Expand Up @@ -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" >}}
Expand Down Expand Up @@ -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" >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 >}}
Expand Down Expand Up @@ -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" >}}
Expand Down Expand Up @@ -126,7 +126,7 @@ Veja um exemplo de prompt </a>.
{{< /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" >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" >}}
Expand Down Expand Up @@ -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" >}}
Expand Down Expand Up @@ -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" >}}
Expand Down