Skip to content

Commit 3f8cae8

Browse files
committed
Get attribute value
1 parent be90e2f commit 3f8cae8

20 files changed

+128
-128
lines changed

dotnet/test/common/BiDi/Input/DefaultKeyboardTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
// .PointerUp(0)
3535
// .Type("abc def"));
3636

37-
// Assert.That(driver.FindElement(By.Id("textInput")).GetAttribute("value"), Is.EqualTo("abc def"));
37+
// Assert.That(driver.FindElement(By.Id("textInput")).GetDomProperty("value"), Is.EqualTo("abc def"));
3838
// }
3939

4040
// [Test]
@@ -86,7 +86,7 @@
8686
// .KeyUp(Key.Shift));
8787

8888
// Assert.That(driver.FindElement(By.Id("result")).Text, Does.EndWith("keydown keydown keypress keyup keydown keypress keyup keyup"));
89-
// Assert.That(driver.FindElement(By.Id("theworks")).GetAttribute("value"), Is.EqualTo("AB"));
89+
// Assert.That(driver.FindElement(By.Id("theworks")).GetDomProperty("value"), Is.EqualTo("AB"));
9090
// }
9191

9292
// [Test]

dotnet/test/common/ClearTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public void WritableTextInputShouldClear()
3131
driver.Url = readOnlyPage;
3232
IWebElement element = driver.FindElement(By.Id("writableTextInput"));
3333
element.Clear();
34-
Assert.That(element.GetAttribute("value"), Is.Empty);
34+
Assert.That(element.GetDomProperty("value"), Is.Empty);
3535
}
3636

3737
[Test]
@@ -63,7 +63,7 @@ public void WritableTextAreaShouldClear()
6363
driver.Url = readOnlyPage;
6464
IWebElement element = driver.FindElement(By.Id("writableTextArea"));
6565
element.Clear();
66-
Assert.That(element.GetAttribute("value"), Is.Empty);
66+
Assert.That(element.GetDomProperty("value"), Is.Empty);
6767
}
6868

6969
[Test]
@@ -202,10 +202,10 @@ private void ShouldBeAbleToClearInput(By locator, string oldValue, string cleare
202202
{
203203
driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("inputs.html");
204204
IWebElement element = driver.FindElement(locator);
205-
Assert.That(element.GetAttribute("value"), Is.EqualTo(oldValue));
205+
Assert.That(element.GetDomProperty("value"), Is.EqualTo(oldValue));
206206

207207
element.Clear();
208-
Assert.That(element.GetAttribute("value"), Is.EqualTo(clearedValue));
208+
Assert.That(element.GetDomProperty("value"), Is.EqualTo(clearedValue));
209209
}
210210
}
211211
}

dotnet/test/common/CorrectEventFiringTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ public void ShouldEmitClickEventWhenClickingOnATextInputElement()
245245
IWebElement clicker = driver.FindElement(By.Id("clickField"));
246246
clicker.Click();
247247

248-
Assert.That(clicker.GetAttribute("value"), Is.EqualTo("Clicked"));
248+
Assert.That(clicker.GetDomProperty("value"), Is.EqualTo("Clicked"));
249249
}
250250

251251
[Test]

dotnet/test/common/ElementAttributeTest.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ public void ShouldReturnTheContentsOfATextAreaAsItsValue()
222222
{
223223
driver.Url = formsPage;
224224

225-
String value = driver.FindElement(By.Id("withText")).GetAttribute("value");
225+
String value = driver.FindElement(By.Id("withText")).GetDomProperty("value");
226226

227227
Assert.That(value, Is.EqualTo("Example text"));
228228
}
@@ -333,29 +333,29 @@ public void CanRetrieveTheCurrentValueOfATextFormField_textInput()
333333
{
334334
driver.Url = formsPage;
335335
IWebElement element = driver.FindElement(By.Id("working"));
336-
Assert.That(element.GetAttribute("value"), Is.Empty);
336+
Assert.That(element.GetDomProperty("value"), Is.Empty);
337337
element.SendKeys("hello world");
338-
Assert.That(element.GetAttribute("value"), Is.EqualTo("hello world"));
338+
Assert.That(element.GetDomProperty("value"), Is.EqualTo("hello world"));
339339
}
340340

341341
[Test]
342342
public void CanRetrieveTheCurrentValueOfATextFormField_emailInput()
343343
{
344344
driver.Url = formsPage;
345345
IWebElement element = driver.FindElement(By.Id("email"));
346-
Assert.That(element.GetAttribute("value"), Is.Empty);
346+
Assert.That(element.GetDomProperty("value"), Is.Empty);
347347
element.SendKeys("hello world");
348-
Assert.That(element.GetAttribute("value"), Is.EqualTo("hello world"));
348+
Assert.That(element.GetDomProperty("value"), Is.EqualTo("hello world"));
349349
}
350350

351351
[Test]
352352
public void CanRetrieveTheCurrentValueOfATextFormField_textArea()
353353
{
354354
driver.Url = formsPage;
355355
IWebElement element = driver.FindElement(By.Id("emptyTextArea"));
356-
Assert.That(element.GetAttribute("value"), Is.Empty);
356+
Assert.That(element.GetDomProperty("value"), Is.Empty);
357357
element.SendKeys("hello world");
358-
Assert.That(element.GetAttribute("value"), Is.EqualTo("hello world"));
358+
Assert.That(element.GetDomProperty("value"), Is.EqualTo("hello world"));
359359
}
360360

361361
[Test]

dotnet/test/common/ElementFindingTest.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public void ShouldBeAbleToFindASingleElementByName()
135135
{
136136
driver.Url = formsPage;
137137
IWebElement element = driver.FindElement(By.Name("checky"));
138-
Assert.That(element.GetAttribute("value"), Is.EqualTo("furrfu"));
138+
Assert.That(element.GetDomProperty("value"), Is.EqualTo("furrfu"));
139139
}
140140

141141
[Test]
@@ -417,7 +417,7 @@ public void ShouldBeAbleToFindAnElementByXPathWithMultipleAttributes()
417417
IWebElement element = driver.FindElement(
418418
By.XPath("//form[@name='optional']/input[@type='submit' and @value='Click!']"));
419419
Assert.That(element.TagName.ToLower(), Is.EqualTo("input"));
420-
Assert.That(element.GetAttribute("value"), Is.EqualTo("Click!"));
420+
Assert.That(element.GetDomProperty("value"), Is.EqualTo("Click!"));
421421
}
422422

423423
[Test]
@@ -594,23 +594,23 @@ public void ShouldBeAbleToFindAnElementByBooleanAttributeUsingCssSelector()
594594
{
595595
driver.Url = (EnvironmentManager.Instance.UrlBuilder.WhereIs("locators_tests/boolean_attribute_selected.html"));
596596
IWebElement element = driver.FindElement(By.CssSelector("option[selected='selected']"));
597-
Assert.That(element.GetAttribute("value"), Is.EqualTo("two"));
597+
Assert.That(element.GetDomProperty("value"), Is.EqualTo("two"));
598598
}
599599

600600
[Test]
601601
public void ShouldBeAbleToFindAnElementByBooleanAttributeUsingShortCssSelector()
602602
{
603603
driver.Url = (EnvironmentManager.Instance.UrlBuilder.WhereIs("locators_tests/boolean_attribute_selected.html"));
604604
IWebElement element = driver.FindElement(By.CssSelector("option[selected]"));
605-
Assert.That(element.GetAttribute("value"), Is.EqualTo("two"));
605+
Assert.That(element.GetDomProperty("value"), Is.EqualTo("two"));
606606
}
607607

608608
[Test]
609609
public void ShouldBeAbleToFindAnElementByBooleanAttributeUsingShortCssSelectorOnHtml4Page()
610610
{
611611
driver.Url = (EnvironmentManager.Instance.UrlBuilder.WhereIs("locators_tests/boolean_attribute_selected_html4.html"));
612612
IWebElement element = driver.FindElement(By.CssSelector("option[selected]"));
613-
Assert.That(element.GetAttribute("value"), Is.EqualTo("two"));
613+
Assert.That(element.GetDomProperty("value"), Is.EqualTo("two"));
614614
}
615615

616616
// By.CssSelector negative
@@ -798,16 +798,16 @@ public void WhenFindingByNameShouldNotReturnById()
798798
driver.Url = formsPage;
799799

800800
IWebElement element = driver.FindElement(By.Name("id-name1"));
801-
Assert.That(element.GetAttribute("value"), Is.EqualTo("name"));
801+
Assert.That(element.GetDomProperty("value"), Is.EqualTo("name"));
802802

803803
element = driver.FindElement(By.Id("id-name1"));
804-
Assert.That(element.GetAttribute("value"), Is.EqualTo("id"));
804+
Assert.That(element.GetDomProperty("value"), Is.EqualTo("id"));
805805

806806
element = driver.FindElement(By.Name("id-name2"));
807-
Assert.That(element.GetAttribute("value"), Is.EqualTo("name"));
807+
Assert.That(element.GetDomProperty("value"), Is.EqualTo("name"));
808808

809809
element = driver.FindElement(By.Id("id-name2"));
810-
Assert.That(element.GetAttribute("value"), Is.EqualTo("id"));
810+
Assert.That(element.GetDomProperty("value"), Is.EqualTo("id"));
811811
}
812812

813813
[Test]
@@ -912,7 +912,7 @@ public void ShouldFindElementsByName()
912912

913913
IWebElement element = driver.FindElement(By.Name("checky"));
914914

915-
Assert.That(element.GetAttribute("value"), Is.EqualTo("furrfu"));
915+
Assert.That(element.GetDomProperty("value"), Is.EqualTo("furrfu"));
916916
}
917917

918918
[Test]

dotnet/test/common/ExecutingAsyncJavascriptTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ public void ShouldBeAbleToExecuteAsynchronousScripts()
238238

239239
IWebElement typer = driver.FindElement(By.Name("typer"));
240240
typer.SendKeys("bob");
241-
Assert.That(typer.GetAttribute("value"), Is.EqualTo("bob"));
241+
Assert.That(typer.GetDomProperty("value"), Is.EqualTo("bob"));
242242

243243
driver.FindElement(By.Id("red")).Click();
244244
driver.FindElement(By.Name("submit")).Click();
@@ -250,7 +250,7 @@ public void ShouldBeAbleToExecuteAsynchronousScripts()
250250
"var callback = arguments[arguments.length - 1];"
251251
+ "window.registerListener(arguments[arguments.length - 1]);");
252252
Assert.That(text, Is.EqualTo("bob"));
253-
Assert.That(typer.GetAttribute("value"), Is.Empty);
253+
Assert.That(typer.GetDomProperty("value"), Is.Empty);
254254

255255
Assert.That(GetNumberOfDivElements(), Is.EqualTo(2), "There should be 1 DIV (for the butter message) + 1 DIV (for the new label)");
256256
}

dotnet/test/common/FormHandlingTests.cs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public void ShouldBeAbleToEnterTextIntoATextAreaBySettingItsValue()
111111
IWebElement textarea = driver.FindElement(By.Id("keyUpArea"));
112112
string cheesey = "Brie and cheddar";
113113
textarea.SendKeys(cheesey);
114-
Assert.That(textarea.GetAttribute("value"), Is.EqualTo(cheesey));
114+
Assert.That(textarea.GetDomProperty("value"), Is.EqualTo(cheesey));
115115
}
116116

117117
[Test]
@@ -121,7 +121,7 @@ public void SendKeysKeepsCapitalization()
121121
IWebElement textarea = driver.FindElement(By.Id("keyUpArea"));
122122
string cheesey = "BrIe And CheDdar";
123123
textarea.SendKeys(cheesey);
124-
Assert.That(textarea.GetAttribute("value"), Is.EqualTo(cheesey));
124+
Assert.That(textarea.GetDomProperty("value"), Is.EqualTo(cheesey));
125125
}
126126

127127
[Test]
@@ -156,14 +156,14 @@ public void ShouldEnterDataIntoFormFields()
156156
{
157157
driver.Url = xhtmlTestPage;
158158
IWebElement element = driver.FindElement(By.XPath("//form[@name='someForm']/input[@id='username']"));
159-
String originalValue = element.GetAttribute("value");
159+
String originalValue = element.GetDomProperty("value");
160160
Assert.That(originalValue, Is.EqualTo("change"));
161161

162162
element.Clear();
163163
element.SendKeys("some text");
164164

165165
element = driver.FindElement(By.XPath("//form[@name='someForm']/input[@id='username']"));
166-
String newFormValue = element.GetAttribute("value");
166+
String newFormValue = element.GetDomProperty("value");
167167
Assert.That(newFormValue, Is.EqualTo("some text"));
168168
}
169169

@@ -173,7 +173,7 @@ public void ShouldBeAbleToAlterTheContentsOfAFileUploadInputElement()
173173
string testFileName = string.Format("test-{0}.txt", Guid.NewGuid().ToString("D"));
174174
driver.Url = formsPage;
175175
IWebElement uploadElement = driver.FindElement(By.Id("upload"));
176-
Assert.That(uploadElement.GetAttribute("value"), Is.Null.Or.Empty);
176+
Assert.That(uploadElement.GetDomProperty("value"), Is.Null.Or.Empty);
177177

178178
string filePath = System.IO.Path.Combine(EnvironmentManager.Instance.CurrentDirectory, testFileName);
179179
System.IO.FileInfo inputFile = new System.IO.FileInfo(filePath);
@@ -183,7 +183,7 @@ public void ShouldBeAbleToAlterTheContentsOfAFileUploadInputElement()
183183

184184
uploadElement.SendKeys(inputFile.FullName);
185185

186-
string uploadElementValue = uploadElement.GetAttribute("value");
186+
string uploadElementValue = uploadElement.GetDomProperty("value");
187187
System.IO.FileInfo outputFile = new System.IO.FileInfo(uploadElementValue.Replace('\\', System.IO.Path.DirectorySeparatorChar));
188188
Assert.That(inputFile.Name, Is.EqualTo(outputFile.Name));
189189
inputFile.Delete();
@@ -201,7 +201,7 @@ public void ShouldBeAbleToSendKeysToAFileUploadInputElementInAnXhtmlDocument()
201201

202202
driver.Url = xhtmlFormPage;
203203
IWebElement uploadElement = driver.FindElement(By.Id("file"));
204-
Assert.That(uploadElement.GetAttribute("value"), Is.Empty);
204+
Assert.That(uploadElement.GetDomProperty("value"), Is.Empty);
205205

206206
string testFileName = string.Format("test-{0}.txt", Guid.NewGuid().ToString("D"));
207207
string filePath = System.IO.Path.Combine(EnvironmentManager.Instance.CurrentDirectory, testFileName);
@@ -212,7 +212,7 @@ public void ShouldBeAbleToSendKeysToAFileUploadInputElementInAnXhtmlDocument()
212212

213213
uploadElement.SendKeys(inputFile.FullName);
214214

215-
string uploadElementValue = uploadElement.GetAttribute("value");
215+
string uploadElementValue = uploadElement.GetDomProperty("value");
216216
System.IO.FileInfo outputFile = new System.IO.FileInfo(uploadElementValue.Replace('\\', System.IO.Path.DirectorySeparatorChar));
217217
Assert.That(outputFile.Name, Is.EqualTo(inputFile.Name));
218218
inputFile.Delete();
@@ -233,7 +233,7 @@ public void ShouldBeAbleToUploadTheSameFileTwice()
233233
{
234234
driver.Url = formsPage;
235235
IWebElement uploadElement = driver.FindElement(By.Id("upload"));
236-
Assert.That(uploadElement.GetAttribute("value"), Is.Null.Or.EqualTo(string.Empty));
236+
Assert.That(uploadElement.GetDomProperty("value"), Is.Null.Or.EqualTo(string.Empty));
237237

238238
uploadElement.SendKeys(inputFile.FullName);
239239
uploadElement.Submit();
@@ -252,11 +252,11 @@ public void SendingKeyboardEventsShouldAppendTextInInputs()
252252
driver.Url = formsPage;
253253
IWebElement element = driver.FindElement(By.Id("working"));
254254
element.SendKeys("Some");
255-
String value = element.GetAttribute("value");
255+
String value = element.GetDomProperty("value");
256256
Assert.That(value, Is.EqualTo("Some"));
257257

258258
element.SendKeys(" text");
259-
value = element.GetAttribute("value");
259+
value = element.GetDomProperty("value");
260260
Assert.That(value, Is.EqualTo("Some text"));
261261
}
262262

@@ -266,7 +266,7 @@ public void SendingKeyboardEventsShouldAppendTextInInputsWithExistingValue()
266266
driver.Url = formsPage;
267267
IWebElement element = driver.FindElement(By.Id("inputWithText"));
268268
element.SendKeys(". Some text");
269-
string value = element.GetAttribute("value");
269+
string value = element.GetDomProperty("value");
270270

271271
Assert.That(value, Is.EqualTo("Example text. Some text"));
272272
}
@@ -278,7 +278,7 @@ public void SendingKeyboardEventsShouldAppendTextInTextAreas()
278278
IWebElement element = driver.FindElement(By.Id("withText"));
279279

280280
element.SendKeys(". Some text");
281-
String value = element.GetAttribute("value");
281+
String value = element.GetDomProperty("value");
282282

283283
Assert.That(value, Is.EqualTo("Example text. Some text"));
284284
}
@@ -288,10 +288,10 @@ public void EmptyTextBoxesShouldReturnAnEmptyStringNotNull()
288288
{
289289
driver.Url = formsPage;
290290
IWebElement emptyTextBox = driver.FindElement(By.Id("working"));
291-
Assert.That(emptyTextBox.GetAttribute("value"), Is.Empty);
291+
Assert.That(emptyTextBox.GetDomProperty("value"), Is.Empty);
292292

293293
IWebElement emptyTextArea = driver.FindElement(By.Id("emptyTextArea"));
294-
Assert.That(emptyTextBox.GetAttribute("value"), Is.Empty);
294+
Assert.That(emptyTextBox.GetDomProperty("value"), Is.Empty);
295295
}
296296

297297
[Test]
@@ -390,11 +390,11 @@ public void ShouldBeAbleToClearTextFromInputElements()
390390
driver.Url = formsPage;
391391
IWebElement element = driver.FindElement(By.Id("working"));
392392
element.SendKeys("Some text");
393-
String value = element.GetAttribute("value");
393+
String value = element.GetDomProperty("value");
394394
Assert.That(value, Is.Not.Empty);
395395

396396
element.Clear();
397-
value = element.GetAttribute("value");
397+
value = element.GetDomProperty("value");
398398

399399
Assert.That(value, Is.Empty);
400400
}
@@ -405,11 +405,11 @@ public void ShouldBeAbleToClearTextFromTextAreas()
405405
driver.Url = formsPage;
406406
IWebElement element = driver.FindElement(By.Id("withText"));
407407
element.SendKeys("Some text");
408-
String value = element.GetAttribute("value");
408+
String value = element.GetDomProperty("value");
409409
Assert.That(value, Is.Not.Empty);
410410

411411
element.Clear();
412-
value = element.GetAttribute("value");
412+
value = element.GetDomProperty("value");
413413

414414
Assert.That(value, Is.Empty);
415415
}

dotnet/test/common/FrameSwitchingTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public void ShouldBeAbleToSwitchToAnIframeByItsIndex()
9393
driver.Url = iframePage;
9494
driver.SwitchTo().Frame(0);
9595

96-
Assert.That(driver.FindElement(By.Name("id-name1")).GetAttribute("value"), Is.EqualTo("name"));
96+
Assert.That(driver.FindElement(By.Name("id-name1")).GetDomProperty("value"), Is.EqualTo("name"));
9797
}
9898

9999
[Test]
@@ -110,7 +110,7 @@ public void ShouldBeAbleToSwitchToAnIframeByItsName()
110110
{
111111
driver.Url = iframePage;
112112
driver.SwitchTo().Frame("iframe1-name");
113-
Assert.That(driver.FindElement(By.Name("id-name1")).GetAttribute("value"), Is.EqualTo("name"));
113+
Assert.That(driver.FindElement(By.Name("id-name1")).GetDomProperty("value"), Is.EqualTo("name"));
114114

115115
}
116116

@@ -128,7 +128,7 @@ public void ShouldBeAbleToSwitchToAnIframeByItsID()
128128
{
129129
driver.Url = iframePage;
130130
driver.SwitchTo().Frame("iframe1");
131-
Assert.That(driver.FindElement(By.Name("id-name1")).GetAttribute("value"), Is.EqualTo("name"));
131+
Assert.That(driver.FindElement(By.Name("id-name1")).GetDomProperty("value"), Is.EqualTo("name"));
132132
}
133133

134134
[Test]
@@ -154,7 +154,7 @@ public void ShouldBeAbleToSwitchToAnIFrameUsingAPreviouslyLocatedWebElement()
154154
driver.Url = iframePage;
155155
IWebElement frame = driver.FindElement(By.TagName("iframe"));
156156
driver.SwitchTo().Frame(frame);
157-
Assert.That(driver.FindElement(By.Name("id-name1")).GetAttribute("value"), Is.EqualTo("name"));
157+
Assert.That(driver.FindElement(By.Name("id-name1")).GetDomProperty("value"), Is.EqualTo("name"));
158158

159159
}
160160

0 commit comments

Comments
 (0)