Skip to content

Commit 268aa6f

Browse files
added csharp code and update documents (#1838)[deploy site]
* added csharp code and update documents * removed a reference --------- Co-authored-by: Sri Harsha <[email protected]>
1 parent f11c47f commit 268aa6f

File tree

5 files changed

+147
-260
lines changed

5 files changed

+147
-260
lines changed
Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,69 @@
1+
using System;
2+
using System.Drawing;
13
using Microsoft.VisualStudio.TestTools.UnitTesting;
4+
using OpenQA.Selenium;
5+
using OpenQA.Selenium.Chrome;
6+
27

38
namespace SeleniumDocs.Elements
49
{
510
[TestClass]
6-
public class InformationTest : BaseTest
11+
public class InformationTest
712
{
13+
[TestMethod]
14+
public void TestInformationCommands(){
15+
WebDriver driver = new ChromeDriver();
16+
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(500);
17+
18+
// Navigate to Url
19+
driver.Url= "https://www.selenium.dev/selenium/web/inputs.html";
20+
// isDisplayed
21+
// Get boolean value for is element display
22+
bool isEmailVisible = driver.FindElement(By.Name("email_input")).Displayed;
23+
Assert.AreEqual(isEmailVisible, true);
24+
25+
//isEnabled
26+
//returns true if element is enabled else returns false
27+
bool isEnabledButton = driver.FindElement(By.Name("button_input")).Enabled;
28+
Assert.AreEqual(isEnabledButton, true);
29+
30+
//isSelected
31+
//returns true if element is checked else returns false
32+
bool isSelectedCheck = driver.FindElement(By.Name("checkbox_input")).Selected;
33+
Assert.AreEqual(isSelectedCheck, true);
34+
35+
//TagName
36+
//returns TagName of the element
37+
string tagNameInp = driver.FindElement(By.Name("email_input")).TagName;
38+
Assert.AreEqual(tagNameInp, "input");
39+
40+
//Get Location and Size
41+
//Get Location
42+
IWebElement rangeElement = driver.FindElement(By.Name("range_input"));
43+
Point point = rangeElement.Location;
44+
Assert.IsNotNull(point.X);
45+
//Get Size
46+
int height=rangeElement.Size.Height;
47+
Assert.IsNotNull(height);
48+
49+
// Retrieves the computed style property 'font-size' of field
50+
string cssValue = driver.FindElement(By.Name("color_input")).GetCssValue("font-size");
51+
Assert.AreEqual(cssValue, "13.3333px");
52+
53+
//GetText
54+
// Retrieves the text of the element
55+
string text = driver.FindElement(By.TagName("h1")).Text;
56+
Assert.AreEqual(text, "Testing Inputs");
57+
58+
//FetchAttributes
59+
//identify the email text box
60+
IWebElement emailTxt = driver.FindElement(By.Name("email_input"));
61+
//fetch the value property associated with the textbox
62+
string valueInfo = emailTxt.GetAttribute("value");
63+
Assert.AreEqual(valueInfo, "admin@localhost");
64+
65+
//Quit the driver
66+
driver.Quit();
67+
}
868
}
969
}

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

Lines changed: 23 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,7 @@ driver.get("https://www.selenium.dev/selenium/web/inputs.html")
3737
is_email_visible = driver.find_element(By.NAME, "email_input").is_displayed()
3838
{{< /tab >}}
3939
{{< tab header="CSharp" >}}
40-
//Navigate to the url
41-
driver.Url = "https://www.selenium.dev/selenium/web/inputs.html";
42-
43-
//Get boolean value for is element display
44-
Boolean is_email_visible = driver.FindElement(By.Name("email_input")).Displayed;
40+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L18-L23" >}}
4541
{{< /tab >}}
4642
{{< tab header="Ruby" text=true >}}
4743
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L12">}}
@@ -79,16 +75,9 @@ driver.get("https://www.selenium.dev/selenium/web/inputs.html")
7975
# Returns true if element is enabled else returns false
8076
value = driver.find_element(By.NAME, 'button_input').is_enabled()
8177
{{< /tab >}}
82-
{{< tab header="CSharp" >}}
83-
// Navigate to Url
84-
driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/inputs.html");
85-
86-
// Store the WebElement
87-
IWebElement element = driver.FindElement(By.Name("button_input"));
88-
89-
// Prints true if element is enabled else returns false
90-
System.Console.WriteLine(element.Enabled);
91-
{{< /tab >}}
78+
{{< tab header="CSharp" >}}
79+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L25-L28" >}}
80+
{{< /tab >}}
9281
{{< tab header="Ruby" text=true >}}
9382
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L17">}}
9483
{{< /tab >}}
@@ -124,13 +113,9 @@ driver.get("https://www.selenium.dev/selenium/web/inputs.html")
124113
# Returns true if element is checked else returns false
125114
value = driver.find_element(By.NAME, "checkbox_input").is_selected()
126115
{{< /tab >}}
127-
{{< tab header="CSharp" >}}
128-
// Navigate to Url
129-
driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/inputs.html");
130-
131-
// Returns true if element ins checked else returns false
132-
bool value = driver.FindElement(By.Name("checkbox_input")).Selected;
133-
{{< /tab >}}
116+
{{< tab header="CSharp" >}}
117+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L30-L33" >}}
118+
{{< /tab >}}
134119
{{< tab header="Ruby" text=true >}}
135120
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L22">}}
136121
{{< /tab >}}
@@ -162,13 +147,9 @@ driver.get("https://www.selenium.dev/selenium/web/inputs.html")
162147
# Returns TagName of the element
163148
attr = driver.find_element(By.NAME, "email_input").tag_name
164149
{{< /tab >}}
165-
{{< tab header="CSharp" >}}
166-
// Navigate to Url
167-
driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/inputs.html");
168-
169-
// Returns TagName of the element
170-
string attr = driver.FindElement(By.Name("email_input")).TagName;
171-
{{< /tab >}}
150+
{{< tab header="CSharp" >}}
151+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L35-L38" >}}
152+
{{< /tab >}}
172153
{{< tab header="Ruby" text=true >}}
173154
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L27">}}
174155
{{< /tab >}}
@@ -206,16 +187,9 @@ driver.get("https://www.selenium.dev/selenium/web/inputs.html")
206187
# Returns height, width, x and y coordinates referenced element
207188
res = driver.find_element(By.NAME, "range_input").rect
208189
{{< /tab >}}
209-
{{< tab header="CSharp" >}}
210-
// Navigate to Url
211-
driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/inputs.html");
212-
213-
var res = driver.FindElement(By.Name("range_input"));
214-
// Return x and y coordinates referenced element
215-
System.Console.WriteLine(res.Location);
216-
// Returns height, width
217-
System.Console.WriteLine(res.Size);
218-
{{< /tab >}}
190+
{{< tab header="CSharp" >}}
191+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L40-L47" >}}
192+
{{< /tab >}}
219193
{{< tab header="Ruby" text=true >}}
220194
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L32">}}
221195
{{< /tab >}}
@@ -250,17 +224,10 @@ driver.get('https://www.selenium.dev/selenium/web/colorPage.html')
250224

251225
# Retrieves the computed style property 'color' of linktext
252226
cssValue = driver.find_element(By.ID, "namedColor").value_of_css_property('background-color')
253-
254-
{{< /tab >}}
255-
{{< tab header="CSharp" >}}
256-
257-
// Navigate to Url
258-
driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/colorPage.html");
259-
260-
// Retrieves the computed style property 'color' of linktext
261-
String cssValue = driver.FindElement(By.Id("namedColor")).GetCssValue("background-color");
262-
263-
{{< /tab >}}
227+
{{< /tab >}}
228+
{{< tab header="CSharp" >}}
229+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L49-L51" >}}
230+
{{< /tab >}}
264231
{{< tab header="Ruby" text=true >}}
265232
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L38">}}
266233
{{< /tab >}}
@@ -293,13 +260,9 @@ driver.get("https://www.selenium.dev/selenium/web/linked_image.html")
293260
# Retrieves the text of the element
294261
text = driver.find_element(By.ID, "justanotherlink").text
295262
{{< /tab >}}
296-
{{< tab header="CSharp" >}}
297-
// Navigate to url
298-
driver.Url="https://www.selenium.dev/selenium/web/linked_image.html";
299-
300-
// Retrieves the text of the element
301-
String text = driver.FindElement(By.Id("justanotherlink")).Text;
302-
{{< /tab >}}
263+
{{< tab header="CSharp" >}}
264+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L53-L56" >}}
265+
{{< /tab >}}
303266
{{< tab header="Ruby" text=true >}}
304267
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L43">}}
305268
{{< /tab >}}
@@ -337,16 +300,9 @@ email_txt = driver.find_element(By.NAME, "email_input")
337300
# Fetch the value property associated with the textbox
338301
value_info = email_txt.get_attribute("value")
339302
{{< /tab >}}
340-
{{< tab header="CSharp" >}}
341-
//Navigate to the url
342-
driver.Url="https://www.selenium.dev/selenium/web/inputs.html";
343-
344-
//identify the email text box
345-
IWebElement emailTxt = driver.FindElement(By.Name(("email_input")));
346-
347-
//fetch the value property associated with the textbox
348-
String valueInfo = eleSelLink.GetAttribute("value");
349-
{{< /tab >}}
303+
{{< tab header="CSharp" >}}
304+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L58-L63" >}}
305+
{{< /tab >}}
350306
{{< tab header="Ruby" text=true >}}
351307
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L48">}}
352308
{{< /tab >}}

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

Lines changed: 21 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,7 @@ driver.get("https://www.selenium.dev/selenium/web/inputs.html")
3737
is_email_visible = driver.find_element(By.NAME, "email_input").is_displayed()
3838
{{< /tab >}}
3939
{{< tab header="CSharp" >}}
40-
//Navigate to the url
41-
driver.Url = "https://www.selenium.dev/selenium/web/inputs.html";
42-
43-
//Get boolean value for is element display
44-
Boolean is_email_visible = driver.FindElement(By.Name("email_input")).Displayed;
40+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L18-L23" >}}
4541
{{< /tab >}}
4642
{{< tab header="Ruby" text=true >}}
4743
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L12">}}
@@ -76,16 +72,9 @@ driver.get("https://www.selenium.dev/selenium/web/inputs.html")
7672
# Returns true if element is enabled else returns false
7773
value = driver.find_element(By.NAME, 'button_input').is_enabled()
7874
{{< /tab >}}
79-
{{< tab header="CSharp" >}}
80-
// Navigate to Url
81-
driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/inputs.html");
82-
83-
// Store the WebElement
84-
IWebElement element = driver.FindElement(By.Name("button_input"));
85-
86-
// Prints true if element is enabled else returns false
87-
System.Console.WriteLine(element.Enabled);
88-
{{< /tab >}}
75+
{{< tab header="CSharp" >}}
76+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L25-L28" >}}
77+
{{< /tab >}}
8978
{{< tab header="Ruby" text=true >}}
9079
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L17">}}
9180
{{< /tab >}}
@@ -119,13 +108,9 @@ driver.get("https://www.selenium.dev/selenium/web/inputs.html")
119108
# Returns true if element is checked else returns false
120109
value = driver.find_element(By.NAME, "checkbox_input").is_selected()
121110
{{< /tab >}}
122-
{{< tab header="CSharp" >}}
123-
// Navigate to Url
124-
driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/inputs.html");
125-
126-
// Returns true if element ins checked else returns false
127-
bool value = driver.FindElement(By.Name("checkbox_input")).Selected;
128-
{{< /tab >}}
111+
{{< tab header="CSharp" >}}
112+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L30-L33" >}}
113+
{{< /tab >}}
129114
{{< tab header="Ruby" text=true >}}
130115
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L22">}}
131116
{{< /tab >}}
@@ -158,12 +143,8 @@ driver.get("https://www.selenium.dev/selenium/web/inputs.html")
158143
attr = driver.find_element(By.NAME, "email_input").tag_name
159144
{{< /tab >}}
160145
{{< tab header="CSharp" >}}
161-
// Navigate to Url
162-
driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/inputs.html");
163-
164-
// Returns TagName of the element
165-
string attr = driver.FindElement(By.Name("email_input")).TagName;
166-
{{< /tab >}}
146+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L35-L38" >}}
147+
{{< /tab >}}
167148
{{< tab header="Ruby" text=true >}}
168149
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L27">}}
169150
{{< /tab >}}
@@ -201,16 +182,9 @@ driver.get("https://www.selenium.dev/selenium/web/inputs.html")
201182
# Returns height, width, x and y coordinates referenced element
202183
res = driver.find_element(By.NAME, "range_input").rect
203184
{{< /tab >}}
204-
{{< tab header="CSharp" >}}
205-
// Navigate to Url
206-
driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/inputs.html");
207-
208-
var res = driver.FindElement(By.Name("range_input"));
209-
// Return x and y coordinates referenced element
210-
System.Console.WriteLine(res.Location);
211-
// Returns height, width
212-
System.Console.WriteLine(res.Size);
213-
{{< /tab >}}
185+
{{< tab header="CSharp" >}}
186+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L40-L47" >}}
187+
{{< /tab >}}
214188
{{< tab header="Ruby" text=true >}}
215189
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L32">}}
216190
{{< /tab >}}
@@ -246,15 +220,9 @@ driver.get('https://www.selenium.dev/selenium/web/colorPage.html')
246220
cssValue = driver.find_element(By.ID, "namedColor").value_of_css_property('background-color')
247221

248222
{{< /tab >}}
249-
{{< tab header="CSharp" >}}
250-
251-
// Navigate to Url
252-
driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/colorPage.html");
253-
254-
// Retrieves the computed style property 'color' of linktext
255-
String cssValue = driver.FindElement(By.Id("namedColor")).GetCssValue("background-color");
256-
257-
{{< /tab >}}
223+
{{< tab header="CSharp" >}}
224+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L49-L51" >}}
225+
{{< /tab >}}
258226
{{< tab header="Ruby" text=true >}}
259227
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L38">}}
260228
{{< /tab >}}
@@ -288,13 +256,9 @@ driver.get("https://www.selenium.dev/selenium/web/linked_image.html")
288256
# Retrieves the text of the element
289257
text = driver.find_element(By.ID, "justanotherlink").text
290258
{{< /tab >}}
291-
{{< tab header="CSharp" >}}
292-
// Navigate to url
293-
driver.Url="https://www.selenium.dev/selenium/web/linked_image.html";
294-
295-
// Retrieves the text of the element
296-
String text = driver.FindElement(By.Id("justanotherlink")).Text;
297-
{{< /tab >}}
259+
{{< tab header="CSharp" >}}
260+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L53-L56" >}}
261+
{{< /tab >}}
298262
{{< tab header="Ruby" text=true >}}
299263
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L43">}}
300264
{{< /tab >}}
@@ -330,16 +294,9 @@ email_txt = driver.find_element(By.NAME, "email_input")
330294
# Fetch the value property associated with the textbox
331295
value_info = email_txt.get_attribute("value")
332296
{{< /tab >}}
333-
{{< tab header="CSharp" >}}
334-
//Navigate to the url
335-
driver.Url="https://www.selenium.dev/selenium/web/inputs.html";
336-
337-
//identify the email text box
338-
IWebElement emailTxt = driver.FindElement(By.Name(("email_input")));
339-
340-
//fetch the value property associated with the textbox
341-
String valueInfo = eleSelLink.GetAttribute("value");
342-
{{< /tab >}}
297+
{{< tab header="CSharp" >}}
298+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InformationTest.cs#L58-L63" >}}
299+
{{< /tab >}}
343300
{{< tab header="Ruby" text=true >}}
344301
{{< gh-codeblock path="/examples/ruby/spec/elements/information_spec.rb#L48">}}
345302
{{< /tab >}}

0 commit comments

Comments
 (0)