Skip to content

[py] move information code to files #2093

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 5, 2024
Merged
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
45 changes: 45 additions & 0 deletions examples/python/tests/elements/test_information.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,47 @@
from selenium import webdriver
from selenium.webdriver.common.by import By

import pytest


def test_informarion():
# Initialize WebDriver
driver = webdriver.Chrome()
driver.implicitly_wait(0.5)

driver.get("https://www.selenium.dev/selenium/web/inputs.html")

# isDisplayed
is_email_visible = driver.find_element(By.NAME, "email_input").is_displayed()
assert is_email_visible == True

# isEnabled
is_enabled_button = driver.find_element(By.NAME, "button_input").is_enabled()
assert is_enabled_button == True

# isSelected
is_selected_check = driver.find_element(By.NAME, "checkbox_input").is_selected()
assert is_selected_check == True

# TagName
tag_name_inp = driver.find_element(By.NAME, "email_input").tag_name
assert tag_name_inp == "input"

# GetRect
rect = driver.find_element(By.NAME, "range_input").rect
assert rect["x"] == 10

# CSS Value
css_value = driver.find_element(By.NAME, "color_input").value_of_css_property(
"font-size"
)
assert css_value == "13.3333px"

# GetText
text = driver.find_element(By.TAG_NAME, "h1").text
assert text == "Testing Inputs"

# FetchAttributes
email_txt = driver.find_element(By.NAME, "email_input")
value_info = email_txt.get_attribute("value")
assert value_info == "admin@localhost"
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,8 @@ nature and relationship in the tree to return a value.
{{< tab header="Java" text=true >}}
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L20-L25" >}}
{{< /tab >}}
{{< tab header="Python" >}}
# Navigate to the url
driver.get("https://www.selenium.dev/selenium/web/inputs.html")

# Get boolean value for is element display
is_email_visible = driver.find_element(By.NAME, "email_input").is_displayed()
{{< tab header="Python" text=true >}}
{{< gh-codeblock path="examples/python/tests/elements/test_information.py#L12-L15" >}}
{{< /tab >}}
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L18-L23" >}}
Expand Down Expand Up @@ -68,12 +64,8 @@ Returns a boolean value, **True** if the connected element is
{{< tab header="Java" text=true >}}
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L27-L30" >}}
{{< /tab >}}
{{< tab header="Python" >}}
# Navigate to url
driver.get("https://www.selenium.dev/selenium/web/inputs.html")

# Returns true if element is enabled else returns false
value = driver.find_element(By.NAME, 'button_input').is_enabled()
{{< tab header="Python" text=true >}}
{{< gh-codeblock path="examples/python/tests/elements/test_information.py#L19" >}}
{{< /tab >}}
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L25-L28" >}}
Expand Down Expand Up @@ -106,12 +98,8 @@ Returns a boolean value, **True** if referenced element is
{{< tab header="Java" text=true >}}
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L32-L35" >}}
{{< /tab >}}
{{< tab header="Python" >}}
# Navigate to url
driver.get("https://www.selenium.dev/selenium/web/inputs.html")

# Returns true if element is checked else returns false
value = driver.find_element(By.NAME, "checkbox_input").is_selected()
{{< tab header="Python" text=true >}}
{{< gh-codeblock path="examples/python/tests/elements/test_information.py#L23" >}}
{{< /tab >}}
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L30-L33" >}}
Expand Down Expand Up @@ -140,12 +128,8 @@ of the referenced Element which has the focus in the current browsing context.
{{< tab header="Java" text=true >}}
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L37-L40" >}}
{{< /tab >}}
{{< tab header="Python" >}}
# Navigate to url
driver.get("https://www.selenium.dev/selenium/web/inputs.html")

# Returns TagName of the element
attr = driver.find_element(By.NAME, "email_input").tag_name
{{< tab header="Python" text=true >}}
{{< gh-codeblock path="examples/python/tests/elements/test_information.py#L27" >}}
{{< /tab >}}
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L35-L38" >}}
Expand Down Expand Up @@ -180,12 +164,8 @@ The fetched data body contain the following details:
{{< tab header="Java" text=true >}}
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L42-L46" >}}
{{< /tab >}}
{{< tab header="Python" >}}
# Navigate to url
driver.get("https://www.selenium.dev/selenium/web/inputs.html")

# Returns height, width, x and y coordinates referenced element
res = driver.find_element(By.NAME, "range_input").rect
{{< tab header="Python" text=true >}}
{{< gh-codeblock path="examples/python/tests/elements/test_information.py#L31" >}}
{{< /tab >}}
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L40-L47" >}}
Expand Down Expand Up @@ -217,13 +197,8 @@ of an element in the current browsing context.
{{< tab header="Java" text=true >}}
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L49-L51" >}}
{{< /tab >}}
{{< tab header="Python" >}}

# Navigate to Url
driver.get('https://www.selenium.dev/selenium/web/colorPage.html')

# Retrieves the computed style property 'color' of linktext
cssValue = driver.find_element(By.ID, "namedColor").value_of_css_property('background-color')
{{< tab header="Python" text=true >}}
{{< gh-codeblock path="examples/python/tests/elements/test_information.py#L35-L37" >}}
{{< /tab >}}
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L49-L51" >}}
Expand Down Expand Up @@ -253,12 +228,8 @@ Retrieves the rendered text of the specified element.
{{< tab header="Java" text=true >}}
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L54-L57" >}}
{{< /tab >}}
{{< tab header="Python" >}}
# Navigate to url
driver.get("https://www.selenium.dev/selenium/web/linked_image.html")

# Retrieves the text of the element
text = driver.find_element(By.ID, "justanotherlink").text
{{< tab header="Python" text=true >}}
{{< gh-codeblock path="examples/python/tests/elements/test_information.py#L41" >}}
{{< /tab >}}
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L53-L56" >}}
Expand Down Expand Up @@ -290,15 +261,8 @@ with the DOM attribute or property of the element.
{{< tab header="Java" text=true >}}
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L60-L65" >}}
{{< /tab >}}
{{< tab header="Python" >}}
# Navigate to the url
driver.get("https://www.selenium.dev/selenium/web/inputs.html")

# Identify the email text box
email_txt = driver.find_element(By.NAME, "email_input")

# Fetch the value property associated with the textbox
value_info = email_txt.get_attribute("value")
{{< tab header="Python" text=true >}}
{{< gh-codeblock path="examples/python/tests/elements/test_information.py#L44-L46" >}}
{{< /tab >}}
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L58-L63" >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,8 @@ nature and relationship in the tree to return a value.
{{< tab header="Java" text=true >}}
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L20-L25" >}}
{{< /tab >}}
{{< tab header="Python" >}}

# Navigate to the url
driver.get("https://www.selenium.dev/selenium/web/inputs.html")

# Get boolean value for is element display
is_email_visible = driver.find_element(By.NAME, "email_input").is_displayed()

{{< tab header="Python" text=true >}}
{{< gh-codeblock path="examples/python/tests/elements/test_information.py#L12-L15" >}}
{{< /tab >}}
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L18-L23" >}}
Expand Down Expand Up @@ -69,12 +63,8 @@ is_email_visible = driver.find_element(By.NAME, "email_input").is_displayed()
{{< tab header="Java" text=true >}}
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L27-L30" >}}
{{< /tab >}}
{{< tab header="Python" >}}
# Navigate to url
driver.get("https://www.selenium.dev/selenium/web/inputs.html")

# Returns true if element is enabled else returns false
value = driver.find_element(By.NAME, 'button_input').is_enabled()
{{< tab header="Python" text=true >}}
{{< gh-codeblock path="examples/python/tests/elements/test_information.py#L19" >}}
{{< /tab >}}
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L25-L28" >}}
Expand Down Expand Up @@ -105,12 +95,8 @@ value = driver.find_element(By.NAME, 'button_input').is_enabled()
{{< tab header="Java" text=true >}}
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L32-L35" >}}
{{< /tab >}}
{{< tab header="Python" >}}
# Navigate to url
driver.get("https://www.selenium.dev/selenium/web/inputs.html")

# Returns true if element is checked else returns false
value = driver.find_element(By.NAME, "checkbox_input").is_selected()
{{< tab header="Python" text=true >}}
{{< gh-codeblock path="examples/python/tests/elements/test_information.py#L23" >}}
{{< /tab >}}
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L30-L33" >}}
Expand Down Expand Up @@ -139,12 +125,8 @@ val attr = driver.findElement(By.name("checkbox_input")).isSelected()
{{< tab header="Java" text=true >}}
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L37-L40" >}}
{{< /tab >}}
{{< tab header="Python" >}}
# Navigate to url
driver.get("https://www.selenium.dev/selenium/web/inputs.html")

# Returns TagName of the element
attr = driver.find_element(By.NAME, "email_input").tag_name
{{< tab header="Python" text=true >}}
{{< gh-codeblock path="examples/python/tests/elements/test_information.py#L27" >}}
{{< /tab >}}
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L35-L38" >}}
Expand Down Expand Up @@ -179,13 +161,9 @@ val attr = driver.findElement(By.name("email_input")).getTagName()
{{< tab header="Java" text=true >}}
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L42-L46" >}}
{{< /tab >}}
{{< tab header="Python" >}}
# Navigate to url
driver.get("https://www.selenium.dev/selenium/web/inputs.html")

# Returns height, width, x and y coordinates referenced element
res = driver.find_element(By.NAME, "range_input").rect
{{< /tab >}}
{{< tab header="Python" text=true >}}
{{< gh-codeblock path="examples/python/tests/elements/test_information.py#L31" >}}
{{< /tab >}}
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L40-L47" >}}
{{< /tab >}}
Expand Down Expand Up @@ -215,14 +193,9 @@ println(res.getX())
{{< tab header="Java" text=true >}}
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L49-L51" >}}
{{< /tab >}}
{{< tab header="Python" >}}
# Navigate to Url
driver.get('https://www.selenium.dev/selenium/web/colorPage.html')

# Retrieves the computed style property 'color' of linktext
cssValue = driver.find_element(By.ID, "namedColor").value_of_css_property('background-color')

{{< /tab >}}
{{< tab header="Python" text=true >}}
{{< gh-codeblock path="examples/python/tests/elements/test_information.py#L35-L37" >}}
{{< /tab >}}
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L49-L51" >}}
{{< /tab >}}
Expand All @@ -249,12 +222,8 @@ val cssValue = driver.findElement(By.id("namedColor")).getCssValue("background-c
{{< tab header="Java" text=true >}}
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L54-L57" >}}
{{< /tab >}}
{{< tab header="Python" >}}
# Navigate to url
driver.get("https://www.selenium.dev/selenium/web/linked_image.html")

# Retrieves the text of the element
text = driver.find_element(By.ID, "justanotherlink").text
{{< tab header="Python" text=true >}}
{{< gh-codeblock path="examples/python/tests/elements/test_information.py#L41" >}}
{{< /tab >}}
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L53-L56" >}}
Expand Down Expand Up @@ -284,18 +253,9 @@ with the DOM attribute or property of the element.
{{< tab header="Java" text=true >}}
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L60-L65" >}}
{{< /tab >}}
{{< tab header="Python" >}}

# Navigate to the url
driver.get("https://www.selenium.dev/selenium/web/inputs.html")

# Identify the email text box
email_txt = driver.find_element(By.NAME, "email_input")

# Fetch the value property associated with the textbox
value_info = email_txt.get_attribute("value")

{{< /tab >}}
{{< tab header="Python" text=true >}}
{{< gh-codeblock path="examples/python/tests/elements/test_information.py#L44-L46" >}}
{{< /tab >}}
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L58-L63" >}}
{{< /tab >}}
Expand Down
Loading
Loading