Skip to content

Commit 3aa3bef

Browse files
committed
Move information examples
1 parent 3c01e6e commit 3aa3bef

File tree

5 files changed

+132
-236
lines changed

5 files changed

+132
-236
lines changed

examples/ruby/spec/elements/information_spec.rb

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,48 @@
44

55
RSpec.describe 'Element Information' do
66
let(:driver) { start_session }
7+
let(:url) { 'https://www.selenium.dev/selenium/web/inputs.html' }
8+
9+
before { driver.get(url) }
10+
11+
it 'checks if an element is displayed' do
12+
displayed_value = driver.find_element(name: 'email_input').displayed?
13+
expect(displayed_value).to be_truthy
14+
end
15+
16+
it 'checks if an element is enabled' do
17+
enabled_value = driver.find_element(name: 'email_input').enabled?
18+
expect(enabled_value).to be_truthy
19+
end
20+
21+
it 'checks if an element is selected' do
22+
selected_value = driver.find_element(name: 'email_input').selected?
23+
expect(selected_value).to be_falsey
24+
end
25+
26+
it 'gets the tag name of an element' do
27+
tag_name = driver.find_element(name: 'email_input').tag_name
28+
expect(tag_name).to eq('input')
29+
end
30+
31+
it 'gets the size and position of an element' do
32+
size = driver.find_element(name: 'email_input').size
33+
expect(size.width).to eq(147)
34+
expect(size.height).to eq(22)
35+
end
36+
37+
it 'gets the css value of an element' do
38+
css_value = driver.find_element(name: 'email_input').css_value('background-color')
39+
expect(css_value).to eq('rgba(255, 255, 255, 1)')
40+
end
41+
42+
it 'gets the text of an element' do
43+
text = driver.find_element(xpath: '//h1').text
44+
expect(text).to eq('Testing Inputs')
45+
end
46+
47+
it 'gets the attribute value of an element' do
48+
attribute_value = driver.find_element(name: 'number_input').attribute('value')
49+
expect(attribute_value).to eq '42'
50+
end
751
end

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

Lines changed: 22 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,8 @@ driver.Url = "https://www.selenium.dev/selenium/web/inputs.html";
4343
//Get boolean value for is element display
4444
Boolean is_email_visible = driver.FindElement(By.Name("email_input")).Displayed;
4545
{{< /tab >}}
46-
{{< tab header="Ruby" >}}
47-
# Navigate to the url
48-
driver.get("https://www.selenium.dev/selenium/web/inputs.html");
49-
50-
#fetch display status
51-
val = driver.find_element(name: 'email_input').displayed?
46+
{{< tab header="Ruby" text=true >}}
47+
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L12">}}
5248
{{< /tab >}}
5349
{{< tab header="JavaScript" text=true >}}
5450
{{< gh-codeblock path="/examples/javascript/test/elements/information.spec.js#L16-L17">}}
@@ -93,13 +89,9 @@ IWebElement element = driver.FindElement(By.Name("button_input"));
9389
// Prints true if element is enabled else returns false
9490
System.Console.WriteLine(element.Enabled);
9591
{{< /tab >}}
96-
{{< tab header="Ruby" >}}
97-
# Navigate to url
98-
driver.get 'https://www.selenium.dev/selenium/web/inputs.html'
99-
100-
# Returns true if element is enabled else returns false
101-
ele = driver.find_element(name: 'button_input').enabled?
102-
{{< /tab >}}
92+
{{< tab header="Ruby" text=true >}}
93+
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L17">}}
94+
{{< /tab >}}
10395
{{< tab header="JavaScript" text=true >}}
10496
{{< gh-codeblock path="/examples/javascript/test/elements/information.spec.js#L23-L24">}}
10597
{{< /tab >}}
@@ -139,13 +131,9 @@ driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/inputs.html");
139131
// Returns true if element ins checked else returns false
140132
bool value = driver.FindElement(By.Name("checkbox_input")).Selected;
141133
{{< /tab >}}
142-
{{< tab header="Ruby" >}}
143-
# Navigate to url
144-
driver.get 'https://www.selenium.dev/selenium/web/inputs.html'
145-
146-
# Returns true if element is checked else returns false
147-
ele = driver.find_element(name: "checkbox_input").selected?
148-
{{< /tab >}}
134+
{{< tab header="Ruby" text=true >}}
135+
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L22">}}
136+
{{< /tab >}}
149137
{{< tab header="JavaScript" text=true >}}
150138
{{< gh-codeblock path="/examples/javascript/test/elements/information.spec.js#L30-L31">}}
151139
{{< /tab >}}
@@ -181,13 +169,9 @@ driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/inputs.html");
181169
// Returns TagName of the element
182170
string attr = driver.FindElement(By.Name("email_input")).TagName;
183171
{{< /tab >}}
184-
{{< tab header="Ruby" >}}
185-
# Navigate to url
186-
driver.get 'https://www.selenium.dev/selenium/web/inputs.html'
187-
188-
# Returns TagName of the element
189-
attr = driver.find_element(name: "email_input").tag_name
190-
{{< /tab >}}
172+
{{< tab header="Ruby" text=true >}}
173+
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L27">}}
174+
{{< /tab >}}
191175
{{< tab header="JavaScript" text=true >}}
192176
{{< gh-codeblock path="/examples/javascript/test/elements/information.spec.js#L37-L38">}}
193177
{{< /tab >}}
@@ -232,13 +216,9 @@ System.Console.WriteLine(res.Location);
232216
// Returns height, width
233217
System.Console.WriteLine(res.Size);
234218
{{< /tab >}}
235-
{{< tab header="Ruby" >}}
236-
# Navigate to url
237-
driver.get 'https://www.selenium.dev/selenium/web/inputs.html'
238-
239-
# Returns height, width, x and y coordinates referenced element
240-
res = driver.find_element(name: "range_input").rect
241-
{{< /tab >}}
219+
{{< tab header="Ruby" text=true >}}
220+
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L32">}}
221+
{{< /tab >}}
242222
{{< tab header="JavaScript" text=true >}}
243223
{{< gh-codeblock path="/examples/javascript/test/elements/information.spec.js#L45">}}
244224
{{< /tab >}}
@@ -281,14 +261,8 @@ driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/colorPage.html"
281261
String cssValue = driver.FindElement(By.Id("namedColor")).GetCssValue("background-color");
282262

283263
{{< /tab >}}
284-
{{< tab header="Ruby" >}}
285-
286-
# Navigate to Url
287-
driver.get 'https://www.selenium.dev/selenium/web/colorPage.html'
288-
289-
# Retrieves the computed style property 'color' of linktext
290-
cssValue = driver.find_element(:id, 'namedColor').css_value('background-color')
291-
264+
{{< tab header="Ruby" text=true >}}
265+
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L38">}}
292266
{{< /tab >}}
293267
{{< tab header="JavaScript" text=true >}}
294268
{{< gh-codeblock path="/examples/javascript/test/elements/information.spec.js#L76-L78">}}
@@ -326,13 +300,9 @@ driver.Url="https://www.selenium.dev/selenium/web/linked_image.html";
326300
// Retrieves the text of the element
327301
String text = driver.FindElement(By.Id("justanotherlink")).Text;
328302
{{< /tab >}}
329-
{{< tab header="Ruby" >}}
330-
# Navigate to url
331-
driver.get 'https://www.selenium.dev/selenium/web/linked_image.html'
332-
333-
# Retrieves the text of the element
334-
text = driver.find_element(:id, 'justanotherlink').text
335-
{{< /tab >}}
303+
{{< tab header="Ruby" text=true >}}
304+
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L43">}}
305+
{{< /tab >}}
336306
{{< tab header="JavaScript" text=true >}}
337307
{{< gh-codeblock path="/examples/javascript/test/elements/information.spec.js#L84-L86">}}
338308
{{< /tab >}}
@@ -377,16 +347,9 @@ IWebElement emailTxt = driver.FindElement(By.Name(("email_input")));
377347
//fetch the value property associated with the textbox
378348
String valueInfo = eleSelLink.GetAttribute("value");
379349
{{< /tab >}}
380-
{{< tab header="Ruby" >}}
381-
# Navigate to the url
382-
driver.get("https://www.selenium.dev/selenium/web/inputs.html");
383-
384-
#identify the email text box
385-
email_element=driver.find_element(name: 'email_input')
386-
387-
#fetch the value property associated with the textbox
388-
emailVal = email_element.attribute("value");
389-
{{< /tab >}}
350+
{{< tab header="Ruby" text=true >}}
351+
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L48">}}
352+
{{< /tab >}}
390353
{{< tab header="JavaScript" text=true >}}
391354
{{< gh-codeblock path="/examples/javascript/test/elements/information.spec.js#L55-L59">}}
392355
{{< /tab >}}

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

Lines changed: 22 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,8 @@ driver.Url = "https://www.selenium.dev/selenium/web/inputs.html";
4343
//Get boolean value for is element display
4444
Boolean is_email_visible = driver.FindElement(By.Name("email_input")).Displayed;
4545
{{< /tab >}}
46-
{{< tab header="Ruby" >}}
47-
# Navigate to the url
48-
driver.get("https://www.selenium.dev/selenium/web/inputs.html");
49-
50-
#fetch display status
51-
val = driver.find_element(name: 'email_input').displayed?
46+
{{< tab header="Ruby" text=true >}}
47+
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L12">}}
5248
{{< /tab >}}
5349
{{< tab header="JavaScript" text=true >}}
5450
{{< gh-codeblock path="/examples/javascript/test/elements/information.spec.js#L16-L17">}}
@@ -90,13 +86,9 @@ IWebElement element = driver.FindElement(By.Name("button_input"));
9086
// Prints true if element is enabled else returns false
9187
System.Console.WriteLine(element.Enabled);
9288
{{< /tab >}}
93-
{{< tab header="Ruby" >}}
94-
# Navigate to url
95-
driver.get 'https://www.selenium.dev/selenium/web/inputs.html'
96-
97-
# Returns true if element is enabled else returns false
98-
ele = driver.find_element(name: 'button_input').enabled?
99-
{{< /tab >}}
89+
{{< tab header="Ruby" text=true >}}
90+
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L17">}}
91+
{{< /tab >}}
10092
{{< tab header="JavaScript" text=true >}}
10193
{{< gh-codeblock path="/examples/javascript/test/elements/information.spec.js#L23-L24">}}
10294
{{< /tab >}}
@@ -134,13 +126,9 @@ driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/inputs.html");
134126
// Returns true if element ins checked else returns false
135127
bool value = driver.FindElement(By.Name("checkbox_input")).Selected;
136128
{{< /tab >}}
137-
{{< tab header="Ruby" >}}
138-
# Navigate to url
139-
driver.get 'https://www.selenium.dev/selenium/web/inputs.html'
140-
141-
# Returns true if element is checked else returns false
142-
ele = driver.find_element(name: "checkbox_input").selected?
143-
{{< /tab >}}
129+
{{< tab header="Ruby" text=true >}}
130+
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L22">}}
131+
{{< /tab >}}
144132
{{< tab header="JavaScript" text=true >}}
145133
{{< gh-codeblock path="/examples/javascript/test/elements/information.spec.js#L30-L31">}}
146134
{{< /tab >}}
@@ -176,13 +164,9 @@ driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/inputs.html");
176164
// Returns TagName of the element
177165
string attr = driver.FindElement(By.Name("email_input")).TagName;
178166
{{< /tab >}}
179-
{{< tab header="Ruby" >}}
180-
# Navigate to url
181-
driver.get 'https://www.selenium.dev/selenium/web/inputs.html'
182-
183-
# Returns TagName of the element
184-
attr = driver.find_element(name: "email_input").tag_name
185-
{{< /tab >}}
167+
{{< tab header="Ruby" text=true >}}
168+
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L27">}}
169+
{{< /tab >}}
186170
{{< tab header="JavaScript" text=true >}}
187171
{{< gh-codeblock path="/examples/javascript/test/elements/information.spec.js#L37-L38">}}
188172
{{< /tab >}}
@@ -227,13 +211,9 @@ System.Console.WriteLine(res.Location);
227211
// Returns height, width
228212
System.Console.WriteLine(res.Size);
229213
{{< /tab >}}
230-
{{< tab header="Ruby" >}}
231-
# Navigate to url
232-
driver.get 'https://www.selenium.dev/selenium/web/inputs.html'
233-
234-
# Returns height, width, x and y coordinates referenced element
235-
res = driver.find_element(name: "range_input").rect
236-
{{< /tab >}}
214+
{{< tab header="Ruby" text=true >}}
215+
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L32">}}
216+
{{< /tab >}}
237217
{{< tab header="JavaScript" text=true >}}
238218
{{< gh-codeblock path="/examples/javascript/test/elements/information.spec.js#L45">}}
239219
{{< /tab >}}
@@ -275,14 +255,8 @@ driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/colorPage.html"
275255
String cssValue = driver.FindElement(By.Id("namedColor")).GetCssValue("background-color");
276256

277257
{{< /tab >}}
278-
{{< tab header="Ruby" >}}
279-
280-
# Navigate to Url
281-
driver.get 'https://www.selenium.dev/selenium/web/colorPage.html'
282-
283-
# Retrieves the computed style property 'color' of linktext
284-
cssValue = driver.find_element(:id, 'namedColor').css_value('background-color')
285-
258+
{{< tab header="Ruby" text=true >}}
259+
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L38">}}
286260
{{< /tab >}}
287261
{{< tab header="JavaScript" text=true >}}
288262
{{< gh-codeblock path="/examples/javascript/test/elements/information.spec.js#L76-L78">}}
@@ -321,13 +295,9 @@ driver.Url="https://www.selenium.dev/selenium/web/linked_image.html";
321295
// Retrieves the text of the element
322296
String text = driver.FindElement(By.Id("justanotherlink")).Text;
323297
{{< /tab >}}
324-
{{< tab header="Ruby" >}}
325-
# Navigate to url
326-
driver.get 'https://www.selenium.dev/selenium/web/linked_image.html'
327-
328-
# Retrieves the text of the element
329-
text = driver.find_element(:id, 'justanotherlink').text
330-
{{< /tab >}}
298+
{{< tab header="Ruby" text=true >}}
299+
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L43">}}
300+
{{< /tab >}}
331301
{{< tab header="JavaScript" text=true >}}
332302
{{< gh-codeblock path="/examples/javascript/test/elements/information.spec.js#L84-L86">}}
333303
{{< /tab >}}
@@ -370,16 +340,9 @@ IWebElement emailTxt = driver.FindElement(By.Name(("email_input")));
370340
//fetch the value property associated with the textbox
371341
String valueInfo = eleSelLink.GetAttribute("value");
372342
{{< /tab >}}
373-
{{< tab header="Ruby" >}}
374-
# Navigate to the url
375-
driver.get("https://www.selenium.dev/selenium/web/inputs.html");
376-
377-
#identify the email text box
378-
email_element=driver.find_element(name: 'email_input')
379-
380-
#fetch the value property associated with the textbox
381-
emailVal = email_element.attribute("value");
382-
{{< /tab >}}
343+
{{< tab header="Ruby" text=true >}}
344+
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L48">}}
345+
{{< /tab >}}
383346
{{< tab header="JavaScript" text=true >}}
384347
{{< gh-codeblock path="/examples/javascript/test/elements/information.spec.js#L55-L59">}}
385348
{{< /tab >}}

0 commit comments

Comments
 (0)