Skip to content

Commit ac6ee26

Browse files
committed
[py] move information code to files
1 parent 940e90d commit ac6ee26

File tree

5 files changed

+115
-251
lines changed

5 files changed

+115
-251
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,47 @@
11
from selenium import webdriver
2+
from selenium.webdriver.common.by import By
23

4+
import pytest
5+
6+
7+
def test_informarion():
8+
# Initialize WebDriver
9+
driver = webdriver.Chrome()
10+
driver.implicitly_wait(0.5)
11+
12+
driver.get("https://www.selenium.dev/selenium/web/inputs.html")
13+
14+
# isDisplayed
15+
is_email_visible = driver.find_element(By.NAME, "email_input").is_displayed()
16+
assert is_email_visible == True
17+
18+
# isEnabled
19+
is_enabled_button = driver.find_element(By.NAME, "button_input").is_enabled()
20+
assert is_enabled_button == True
21+
22+
# isSelected
23+
is_selected_check = driver.find_element(By.NAME, "checkbox_input").is_selected()
24+
assert is_selected_check == True
25+
26+
# TagName
27+
tag_name_inp = driver.find_element(By.NAME, "email_input").tag_name
28+
assert tag_name_inp == "input"
29+
30+
# GetRect
31+
rect = driver.find_element(By.NAME, "range_input").rect
32+
assert rect["x"] == 10
33+
34+
# CSS Value
35+
css_value = driver.find_element(By.NAME, "color_input").value_of_css_property(
36+
"font-size"
37+
)
38+
assert css_value == "13.3333px"
39+
40+
# GetText
41+
text = driver.find_element(By.TAG_NAME, "h1").text
42+
assert text == "Testing Inputs"
43+
44+
# FetchAttributes
45+
email_txt = driver.find_element(By.NAME, "email_input")
46+
value_info = email_txt.get_attribute("value")
47+
assert value_info == "admin@localhost"

website_and_docs/content/documentation/webdriver/elements/information.en.md

Lines changed: 16 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,8 @@ nature and relationship in the tree to return a value.
2929
{{< tab header="Java" text=true >}}
3030
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L20-L25" >}}
3131
{{< /tab >}}
32-
{{< tab header="Python" >}}
33-
# Navigate to the url
34-
driver.get("https://www.selenium.dev/selenium/web/inputs.html")
35-
36-
# Get boolean value for is element display
37-
is_email_visible = driver.find_element(By.NAME, "email_input").is_displayed()
32+
{{< tab header="Python" text=true >}}
33+
{{< gh-codeblock path="examples/python/tests/elements/test_information.py#L12-L15" >}}
3834
{{< /tab >}}
3935
{{< tab header="CSharp" text=true >}}
4036
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L18-L23" >}}
@@ -68,12 +64,8 @@ Returns a boolean value, **True** if the connected element is
6864
{{< tab header="Java" text=true >}}
6965
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L27-L30" >}}
7066
{{< /tab >}}
71-
{{< tab header="Python" >}}
72-
# Navigate to url
73-
driver.get("https://www.selenium.dev/selenium/web/inputs.html")
74-
75-
# Returns true if element is enabled else returns false
76-
value = driver.find_element(By.NAME, 'button_input').is_enabled()
67+
{{< tab header="Python" text=true >}}
68+
{{< gh-codeblock path="examples/python/tests/elements/test_information.py#L19" >}}
7769
{{< /tab >}}
7870
{{< tab header="CSharp" text=true >}}
7971
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L25-L28" >}}
@@ -106,12 +98,8 @@ Returns a boolean value, **True** if referenced element is
10698
{{< tab header="Java" text=true >}}
10799
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L32-L35" >}}
108100
{{< /tab >}}
109-
{{< tab header="Python" >}}
110-
# Navigate to url
111-
driver.get("https://www.selenium.dev/selenium/web/inputs.html")
112-
113-
# Returns true if element is checked else returns false
114-
value = driver.find_element(By.NAME, "checkbox_input").is_selected()
101+
{{< tab header="Python" text=true >}}
102+
{{< gh-codeblock path="examples/python/tests/elements/test_information.py#L23" >}}
115103
{{< /tab >}}
116104
{{< tab header="CSharp" text=true >}}
117105
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L30-L33" >}}
@@ -140,12 +128,8 @@ of the referenced Element which has the focus in the current browsing context.
140128
{{< tab header="Java" text=true >}}
141129
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L37-L40" >}}
142130
{{< /tab >}}
143-
{{< tab header="Python" >}}
144-
# Navigate to url
145-
driver.get("https://www.selenium.dev/selenium/web/inputs.html")
146-
147-
# Returns TagName of the element
148-
attr = driver.find_element(By.NAME, "email_input").tag_name
131+
{{< tab header="Python" text=true >}}
132+
{{< gh-codeblock path="examples/python/tests/elements/test_information.py#L27" >}}
149133
{{< /tab >}}
150134
{{< tab header="CSharp" text=true >}}
151135
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L35-L38" >}}
@@ -180,12 +164,8 @@ The fetched data body contain the following details:
180164
{{< tab header="Java" text=true >}}
181165
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L42-L46" >}}
182166
{{< /tab >}}
183-
{{< tab header="Python" >}}
184-
# Navigate to url
185-
driver.get("https://www.selenium.dev/selenium/web/inputs.html")
186-
187-
# Returns height, width, x and y coordinates referenced element
188-
res = driver.find_element(By.NAME, "range_input").rect
167+
{{< tab header="Python" text=true >}}
168+
{{< gh-codeblock path="examples/python/tests/elements/test_information.py#L31" >}}
189169
{{< /tab >}}
190170
{{< tab header="CSharp" text=true >}}
191171
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L40-L47" >}}
@@ -217,13 +197,8 @@ of an element in the current browsing context.
217197
{{< tab header="Java" text=true >}}
218198
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L49-L51" >}}
219199
{{< /tab >}}
220-
{{< tab header="Python" >}}
221-
222-
# Navigate to Url
223-
driver.get('https://www.selenium.dev/selenium/web/colorPage.html')
224-
225-
# Retrieves the computed style property 'color' of linktext
226-
cssValue = driver.find_element(By.ID, "namedColor").value_of_css_property('background-color')
200+
{{< tab header="Python" text=true >}}
201+
{{< gh-codeblock path="examples/python/tests/elements/test_information.py#L35-L37" >}}
227202
{{< /tab >}}
228203
{{< tab header="CSharp" text=true >}}
229204
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L49-L51" >}}
@@ -253,12 +228,8 @@ Retrieves the rendered text of the specified element.
253228
{{< tab header="Java" text=true >}}
254229
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L54-L57" >}}
255230
{{< /tab >}}
256-
{{< tab header="Python" >}}
257-
# Navigate to url
258-
driver.get("https://www.selenium.dev/selenium/web/linked_image.html")
259-
260-
# Retrieves the text of the element
261-
text = driver.find_element(By.ID, "justanotherlink").text
231+
{{< tab header="Python" text=true >}}
232+
{{< gh-codeblock path="examples/python/tests/elements/test_information.py#L41" >}}
262233
{{< /tab >}}
263234
{{< tab header="CSharp" text=true >}}
264235
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L53-L56" >}}
@@ -290,15 +261,8 @@ with the DOM attribute or property of the element.
290261
{{< tab header="Java" text=true >}}
291262
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L60-L65" >}}
292263
{{< /tab >}}
293-
{{< tab header="Python" >}}
294-
# Navigate to the url
295-
driver.get("https://www.selenium.dev/selenium/web/inputs.html")
296-
297-
# Identify the email text box
298-
email_txt = driver.find_element(By.NAME, "email_input")
299-
300-
# Fetch the value property associated with the textbox
301-
value_info = email_txt.get_attribute("value")
264+
{{< tab header="Python" text=true >}}
265+
{{< gh-codeblock path="examples/python/tests/elements/test_information.py#L44-L46" >}}
302266
{{< /tab >}}
303267
{{< tab header="CSharp" text=true >}}
304268
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L58-L63" >}}

website_and_docs/content/documentation/webdriver/elements/information.ja.md

Lines changed: 19 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,8 @@ nature and relationship in the tree to return a value.
2929
{{< tab header="Java" text=true >}}
3030
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L20-L25" >}}
3131
{{< /tab >}}
32-
{{< tab header="Python" >}}
33-
34-
# Navigate to the url
35-
driver.get("https://www.selenium.dev/selenium/web/inputs.html")
36-
37-
# Get boolean value for is element display
38-
is_email_visible = driver.find_element(By.NAME, "email_input").is_displayed()
39-
32+
{{< tab header="Python" text=true >}}
33+
{{< gh-codeblock path="examples/python/tests/elements/test_information.py#L12-L15" >}}
4034
{{< /tab >}}
4135
{{< tab header="CSharp" text=true >}}
4236
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L18-L23" >}}
@@ -69,12 +63,8 @@ is_email_visible = driver.find_element(By.NAME, "email_input").is_displayed()
6963
{{< tab header="Java" text=true >}}
7064
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L27-L30" >}}
7165
{{< /tab >}}
72-
{{< tab header="Python" >}}
73-
# Navigate to url
74-
driver.get("https://www.selenium.dev/selenium/web/inputs.html")
75-
76-
# Returns true if element is enabled else returns false
77-
value = driver.find_element(By.NAME, 'button_input').is_enabled()
66+
{{< tab header="Python" text=true >}}
67+
{{< gh-codeblock path="examples/python/tests/elements/test_information.py#L19" >}}
7868
{{< /tab >}}
7969
{{< tab header="CSharp" text=true >}}
8070
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L25-L28" >}}
@@ -105,12 +95,8 @@ value = driver.find_element(By.NAME, 'button_input').is_enabled()
10595
{{< tab header="Java" text=true >}}
10696
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L32-L35" >}}
10797
{{< /tab >}}
108-
{{< tab header="Python" >}}
109-
# Navigate to url
110-
driver.get("https://www.selenium.dev/selenium/web/inputs.html")
111-
112-
# Returns true if element is checked else returns false
113-
value = driver.find_element(By.NAME, "checkbox_input").is_selected()
98+
{{< tab header="Python" text=true >}}
99+
{{< gh-codeblock path="examples/python/tests/elements/test_information.py#L23" >}}
114100
{{< /tab >}}
115101
{{< tab header="CSharp" text=true >}}
116102
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L30-L33" >}}
@@ -139,12 +125,8 @@ val attr = driver.findElement(By.name("checkbox_input")).isSelected()
139125
{{< tab header="Java" text=true >}}
140126
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L37-L40" >}}
141127
{{< /tab >}}
142-
{{< tab header="Python" >}}
143-
# Navigate to url
144-
driver.get("https://www.selenium.dev/selenium/web/inputs.html")
145-
146-
# Returns TagName of the element
147-
attr = driver.find_element(By.NAME, "email_input").tag_name
128+
{{< tab header="Python" text=true >}}
129+
{{< gh-codeblock path="examples/python/tests/elements/test_information.py#L27" >}}
148130
{{< /tab >}}
149131
{{< tab header="CSharp" text=true >}}
150132
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L35-L38" >}}
@@ -179,13 +161,9 @@ val attr = driver.findElement(By.name("email_input")).getTagName()
179161
{{< tab header="Java" text=true >}}
180162
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L42-L46" >}}
181163
{{< /tab >}}
182-
{{< tab header="Python" >}}
183-
# Navigate to url
184-
driver.get("https://www.selenium.dev/selenium/web/inputs.html")
185-
186-
# Returns height, width, x and y coordinates referenced element
187-
res = driver.find_element(By.NAME, "range_input").rect
188-
{{< /tab >}}
164+
{{< tab header="Python" text=true >}}
165+
{{< gh-codeblock path="examples/python/tests/elements/test_information.py#L31" >}}
166+
{{< /tab >}}
189167
{{< tab header="CSharp" text=true >}}
190168
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L40-L47" >}}
191169
{{< /tab >}}
@@ -215,14 +193,9 @@ println(res.getX())
215193
{{< tab header="Java" text=true >}}
216194
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L49-L51" >}}
217195
{{< /tab >}}
218-
{{< tab header="Python" >}}
219-
# Navigate to Url
220-
driver.get('https://www.selenium.dev/selenium/web/colorPage.html')
221-
222-
# Retrieves the computed style property 'color' of linktext
223-
cssValue = driver.find_element(By.ID, "namedColor").value_of_css_property('background-color')
224-
225-
{{< /tab >}}
196+
{{< tab header="Python" text=true >}}
197+
{{< gh-codeblock path="examples/python/tests/elements/test_information.py#L35-L37" >}}
198+
{{< /tab >}}
226199
{{< tab header="CSharp" text=true >}}
227200
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L49-L51" >}}
228201
{{< /tab >}}
@@ -249,12 +222,8 @@ val cssValue = driver.findElement(By.id("namedColor")).getCssValue("background-c
249222
{{< tab header="Java" text=true >}}
250223
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L54-L57" >}}
251224
{{< /tab >}}
252-
{{< tab header="Python" >}}
253-
# Navigate to url
254-
driver.get("https://www.selenium.dev/selenium/web/linked_image.html")
255-
256-
# Retrieves the text of the element
257-
text = driver.find_element(By.ID, "justanotherlink").text
225+
{{< tab header="Python" text=true >}}
226+
{{< gh-codeblock path="examples/python/tests/elements/test_information.py#L41" >}}
258227
{{< /tab >}}
259228
{{< tab header="CSharp" text=true >}}
260229
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L53-L56" >}}
@@ -284,18 +253,9 @@ with the DOM attribute or property of the element.
284253
{{< tab header="Java" text=true >}}
285254
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InformationTest.java#L60-L65" >}}
286255
{{< /tab >}}
287-
{{< tab header="Python" >}}
288-
289-
# Navigate to the url
290-
driver.get("https://www.selenium.dev/selenium/web/inputs.html")
291-
292-
# Identify the email text box
293-
email_txt = driver.find_element(By.NAME, "email_input")
294-
295-
# Fetch the value property associated with the textbox
296-
value_info = email_txt.get_attribute("value")
297-
298-
{{< /tab >}}
256+
{{< tab header="Python" text=true >}}
257+
{{< gh-codeblock path="examples/python/tests/elements/test_information.py#L44-L46" >}}
258+
{{< /tab >}}
299259
{{< tab header="CSharp" text=true >}}
300260
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L58-L63" >}}
301261
{{< /tab >}}

0 commit comments

Comments
 (0)