diff --git a/examples/python/tests/elements/test_interaction.py b/examples/python/tests/elements/test_interaction.py index 53b695b6fc83..eb05f7d928a1 100644 --- a/examples/python/tests/elements/test_interaction.py +++ b/examples/python/tests/elements/test_interaction.py @@ -1,2 +1,39 @@ from selenium import webdriver +from selenium.webdriver.common.by import By +import pytest + + +def test_interactions(): + # Initialize WebDriver + driver = webdriver.Chrome() + driver.implicitly_wait(0.5) + + # Navigate to URL + driver.get("https://www.selenium.dev/selenium/web/inputs.html") + + # Click on the checkbox + check_input = driver.find_element(By.NAME, "checkbox_input") + check_input.click() + + is_checked = check_input.is_selected() + assert is_checked == False + + # Handle the email input field + email_input = driver.find_element(By.NAME, "email_input") + email_input.clear() # Clear field + + email = "admin@localhost.dev" + email_input.send_keys(email) # Enter text + + # Verify input + data = email_input.get_attribute("value") + assert data == email + + # Clear the email input field again + email_input.clear() + data = email_input.get_attribute("value") + assert data == "" + + # Quit the driver + driver.quit() diff --git a/website_and_docs/content/documentation/webdriver/elements/interactions.en.md b/website_and_docs/content/documentation/webdriver/elements/interactions.en.md index 086537038ee7..d9c30c6eab63 100644 --- a/website_and_docs/content/documentation/webdriver/elements/interactions.en.md +++ b/website_and_docs/content/documentation/webdriver/elements/interactions.en.md @@ -49,12 +49,7 @@ Selenium will return an [element click intercepted](https://w3c.github.io/webdri {{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InteractionTest.java#L18-L22" >}} {{< /tab >}} {{< tab header="Python" >}} - - # Navigate to url - driver.get("https://www.selenium.dev/selenium/web/inputs.html") - - # Click on the element - driver.find_element(By.NAME, "color_input").click() +{{< gh-codeblock path="examples/python/tests/elements/test_interaction.py#L12-L17" >}} {{< /tab >}} {{< tab header="CSharp" text=true >}} @@ -95,17 +90,7 @@ possible keystrokes that WebDriver Supports. {{< /tab >}} {{< tab header="Python" >}} - - - # Navigate to url - driver.get("https://www.selenium.dev/selenium/web/inputs.html") - - # Clear field to empty it from any previous data - driver.find_element(By.NAME, "email_input").clear() - - # Enter Text - driver.find_element(By.NAME, "email_input").send_keys("admin@localhost.dev" ) - +{{< gh-codeblock path="examples/python/tests/elements/test_interaction.py#L22-L27" >}} {{< /tab >}} {{< tab header="CSharp" text=true >}} @@ -147,15 +132,7 @@ with a`content-editable` attribute. If these conditions are not met, {{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InteractionTest.java#L38-L40" >}} {{< /tab >}} {{< tab header="Python" >}} - - - # Navigate to url - driver.get("https://www.selenium.dev/selenium/web/inputs.html") - - # Clear field to empty it from any previous data - driver.find_element(By.NAME, "email_input").clear() - - +{{< gh-codeblock path="examples/python/tests/elements/test_interaction.py#L34" >}} {{< /tab >}} diff --git a/website_and_docs/content/documentation/webdriver/elements/interactions.ja.md b/website_and_docs/content/documentation/webdriver/elements/interactions.ja.md index e0e57066ac5b..7c4dff235373 100644 --- a/website_and_docs/content/documentation/webdriver/elements/interactions.ja.md +++ b/website_and_docs/content/documentation/webdriver/elements/interactions.ja.md @@ -45,12 +45,7 @@ Selenium will return an [element click intercepted](https://w3c.github.io/webdri {{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InteractionTest.java#L18-L22" >}} {{< /tab >}} {{< tab header="Python" >}} - - # Navigate to url - driver.get("https://www.selenium.dev/selenium/web/inputs.html") - - # Click on the element - driver.find_element(By.NAME, "color_input").click() +{{< gh-codeblock path="examples/python/tests/elements/test_interaction.py#L12-L17" >}} {{< /tab >}} {{< tab header="CSharp" text=true >}} @@ -92,17 +87,7 @@ possible keystrokes that WebDriver Supports. {{< /tab >}} {{< tab header="Python" >}} - - - # Navigate to url - driver.get("https://www.selenium.dev/selenium/web/inputs.html") - - # Clear field to empty it from any previous data - driver.find_element(By.NAME, "email_input").clear() - - # Enter Text - driver.find_element(By.NAME, "email_input").send_keys("admin@localhost.dev" ) - +{{< gh-codeblock path="examples/python/tests/elements/test_interaction.py#L22-L27" >}} {{< /tab >}} {{< tab header="CSharp" text=true >}} @@ -143,15 +128,7 @@ with a`content-editable` attribute. If these conditions are not met, {{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InteractionTest.java#L38-L40" >}} {{< /tab >}} {{< tab header="Python" >}} - - - # Navigate to url - driver.get("https://www.selenium.dev/selenium/web/inputs.html") - - # Clear field to empty it from any previous data - driver.find_element(By.NAME, "email_input").clear() - - +{{< gh-codeblock path="examples/python/tests/elements/test_interaction.py#L34" >}} {{< /tab >}} {{< tab header="CSharp" text=true >}} diff --git a/website_and_docs/content/documentation/webdriver/elements/interactions.pt-br.md b/website_and_docs/content/documentation/webdriver/elements/interactions.pt-br.md index 2dd9a8aceaed..190899af0990 100644 --- a/website_and_docs/content/documentation/webdriver/elements/interactions.pt-br.md +++ b/website_and_docs/content/documentation/webdriver/elements/interactions.pt-br.md @@ -46,12 +46,7 @@ Selenium will return an [element click intercepted](https://w3c.github.io/webdri {{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InteractionTest.java#L18-L22" >}} {{< /tab >}} {{< tab header="Python" >}} - - # Navigate to url - driver.get("https://www.selenium.dev/selenium/web/inputs.html") - - # Click on the element - driver.find_element(By.NAME, "color_input").click() +{{< gh-codeblock path="examples/python/tests/elements/test_interaction.py#L12-L17" >}} {{< /tab >}} {{< tab header="CSharp" text=true >}} @@ -93,17 +88,7 @@ possible keystrokes that WebDriver Supports. {{< /tab >}} {{< tab header="Python" >}} - - - # Navigate to url - driver.get("https://www.selenium.dev/selenium/web/inputs.html") - - # Clear field to empty it from any previous data - driver.find_element(By.NAME, "email_input").clear() - - # Enter Text - driver.find_element(By.NAME, "email_input").send_keys("admin@localhost.dev" ) - +{{< gh-codeblock path="examples/python/tests/elements/test_interaction.py#L22-L27" >}} {{< /tab >}} {{< tab header="CSharp" text=true >}} @@ -144,15 +129,7 @@ with a`content-editable` attribute. If these conditions are not met, {{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InteractionTest.java#L38-L40" >}} {{< /tab >}} {{< tab header="Python" >}} - - - # Navigate to url - driver.get("https://www.selenium.dev/selenium/web/inputs.html") - - # Clear field to empty it from any previous data - driver.find_element(By.NAME, "email_input").clear() - - +{{< gh-codeblock path="examples/python/tests/elements/test_interaction.py#L34" >}} {{< /tab >}} {{< tab header="CSharp" text=true >}} diff --git a/website_and_docs/content/documentation/webdriver/elements/interactions.zh-cn.md b/website_and_docs/content/documentation/webdriver/elements/interactions.zh-cn.md index 570635108a07..a05448a21886 100644 --- a/website_and_docs/content/documentation/webdriver/elements/interactions.zh-cn.md +++ b/website_and_docs/content/documentation/webdriver/elements/interactions.zh-cn.md @@ -48,12 +48,7 @@ Selenium将返回一个 [元素点击中断](https://w3c.github.io/webdriver/#df {{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InteractionTest.java#L18-L22" >}} {{< /tab >}} {{< tab header="Python" >}} - - # Navigate to url - driver.get("https://www.selenium.dev/selenium/web/inputs.html") - - # Click on the element - driver.find_element(By.NAME, "color_input").click() +{{< gh-codeblock path="examples/python/tests/elements/test_interaction.py#L12-L17" >}} {{< /tab >}} {{< tab header="CSharp" text=true >}} @@ -95,17 +90,7 @@ Selenium将返回一个 [元素点击中断](https://w3c.github.io/webdriver/#df {{< /tab >}} {{< tab header="Python" >}} - - - # Navigate to url - driver.get("https://www.selenium.dev/selenium/web/inputs.html") - - # Clear field to empty it from any previous data - driver.find_element(By.NAME, "email_input").clear() - - # Enter Text - driver.find_element(By.NAME, "email_input").send_keys("admin@localhost.dev" ) - +{{< gh-codeblock path="examples/python/tests/elements/test_interaction.py#L22-L27" >}} {{< /tab >}} {{< tab header="CSharp" text=true >}} @@ -148,15 +133,7 @@ Selenium将返回一个 [元素点击中断](https://w3c.github.io/webdriver/#df {{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InteractionTest.java#L38-L40" >}} {{< /tab >}} {{< tab header="Python" >}} - - - # Navigate to url - driver.get("https://www.selenium.dev/selenium/web/inputs.html") - - # Clear field to empty it from any previous data - driver.find_element(By.NAME, "email_input").clear() - - +{{< gh-codeblock path="examples/python/tests/elements/test_interaction.py#L34" >}} {{< /tab >}} {{< tab header="CSharp" text=true >}}