Skip to content
Closed
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
7 changes: 4 additions & 3 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,7 +14,7 @@ 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"
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#L13-L19" >}}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remediation recommended

1. Docs snippet lacks ec import 🐞 Bug ≡ Correctness

The alert docs embed Python code ranges that include wait.until(EC.alert_is_present()), but those
ranges exclude the expected_conditions as EC import that defines EC, so the displayed snippet
has an unresolved identifier for readers copying it.
Agent Prompt
## Issue description
The Python alert examples shown via `gh-codeblock` now include `EC.alert_is_present()` but do not show the import that defines `EC`, making the displayed snippet contain an undefined identifier.

## Issue Context
`EC` is introduced only by `from selenium.webdriver.support import expected_conditions as EC` in the source test file, but the doc pages embed only mid-file line ranges that start at the interaction code.

## Fix Focus Areas
Update the docs so that the Python snippet either (a) includes the import lines in the embedded range, or (b) adds a small explicit import snippet/note adjacent to the codeblock in each language page.

- website_and_docs/content/documentation/webdriver/interactions/alerts.en.md[27-35]
- website_and_docs/content/documentation/webdriver/interactions/alerts.ja.md[23-31]
- website_and_docs/content/documentation/webdriver/interactions/alerts.pt-br.md[27-33]
- website_and_docs/content/documentation/webdriver/interactions/alerts.zh-cn.md[20-27]
- examples/python/tests/interactions/test_alerts.py[1-20]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

{{< /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#L27-L33" >}}
{{< /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#L41-L48" >}}
{{< /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#L13-L19" >}}
{{< /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#L27-L33" >}}
{{< /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#L41-L48" >}}
{{< /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#L13-L19" >}}
{{< /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#L27-L33" >}}
{{< /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#L41-L48" >}}
{{< /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#L13-L19" >}}
{{< /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#L27-L33" >}}
{{< /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#L41-L48" >}}
{{< /tab >}}

{{< tab header="CSharp" >}}
Expand Down
Loading