Skip to content

Commit 8d49d46

Browse files
committed
Replace the deprecated WebElement.getAttribute(String) with getDomAttribute(String) and getDomProperty(String) at many places in the test suite
1 parent f9f5850 commit 8d49d46

File tree

5 files changed

+38
-44
lines changed

5 files changed

+38
-44
lines changed

src/test/java/org/htmlunit/html/HtmlMonthInputTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,10 @@ public void typing() throws Exception {
179179
final WebDriver driver = loadPage2(htmlContent);
180180

181181
final WebElement input = driver.findElement(By.id("foo"));
182+
182183
input.sendKeys("8");
183-
assertEquals(getExpectedAlerts()[0], input.getAttribute("value"));
184+
assertNull(input.getDomAttribute("value"));
185+
assertEquals(getExpectedAlerts()[0], input.getDomProperty("value"));
184186
}
185187

186188
/**

src/test/java/org/htmlunit/html/HtmlOption2Test.java

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
*/
1515
package org.htmlunit.html;
1616

17-
import java.util.Arrays;
1817
import java.util.List;
1918

2019
import org.htmlunit.WebDriverTestCase;
@@ -117,47 +116,44 @@ public void simpleScriptable() throws Exception {
117116
* @throws Exception if the test fails
118117
*/
119118
@Test
120-
@Alerts("oDown,sDown,dDown,oUp,sUp,dUp,")
119+
@Alerts({"oDown", "sDown", "dDown", "oUp", "sUp", "dUp"})
121120
// there seems to be a bug in selenium; for FF >= 10 this triggers
122121
// "sDown,dDown,sUp,dUp,oDown,sDown,dDown,oUp,sUp,dUp," but a
123122
// manual test shows, that this is wrong.
124123
// for Chrome selenium shows only "sUp,dUp," but again
125124
// manual test are showing something different
126-
@BuggyWebDriver(CHROME = "sUp,dUp,",
127-
EDGE = "sUp,dUp,",
128-
FF = "sDown,dDown,sUp,dUp,",
129-
FF_ESR = "sDown,dDown,sUp,dUp,")
125+
@BuggyWebDriver(CHROME = {"sUp", "dUp"},
126+
EDGE = {"sUp", "dUp"},
127+
FF = {"sDown", "dDown", "sUp", "dUp"},
128+
FF_ESR = {"sDown", "dDown", "sUp", "dUp"})
130129
public void onMouse() throws Exception {
131130
final String html = "<html><head><title>foo</title>\n"
132131
+ "<script>\n"
133-
+ " function debug(string) {\n"
134-
+ " document.getElementById('myTextarea').value += string + ',';\n"
135-
+ " }\n"
132+
+ LOG_TEXTAREA_FUNCTION
136133
+ "</script>\n"
137134
+ "</head><body>\n"
138135
+ " <form>\n"
139136
+ " <div"
140-
+ " onMouseDown='debug(\"dDown\");'"
141-
+ " onMouseUp='debug(\"dUp\");'>\n"
137+
+ " onMouseDown='log(\"dDown\");'"
138+
+ " onMouseUp='log(\"dUp\");'>\n"
142139
+ " <select name='select1' size='4'"
143-
+ " onMouseDown='debug(\"sDown\");'"
144-
+ " onMouseUp='debug(\"sUp\");'>\n"
140+
+ " onMouseDown='log(\"sDown\");'"
141+
+ " onMouseUp='log(\"sUp\");'>\n"
145142
+ " <option id='opt1' value='option1'>Option1</option>\n"
146143
+ " <option id='opt2' value='option2' selected='selected'>Option2</option>\n"
147144
+ " <option id='opt3' value='option3'"
148-
+ " onMouseDown='debug(\"oDown\");'"
149-
+ " onMouseUp='debug(\"oUp\");'>Option3</option>\n"
145+
+ " onMouseDown='log(\"oDown\");'"
146+
+ " onMouseUp='log(\"oUp\");'>Option3</option>\n"
150147
+ " </select>\n"
151148
+ " </div>\n"
152149
+ " </form>\n"
153-
+ " <textarea id='myTextarea'></textarea>\n"
150+
+ LOG_TEXTAREA
154151
+ "</body></html>";
155152

156153
final WebDriver driver = loadPage2(html);
157154
driver.findElement(By.id("opt3")).click();
158155

159-
assertEquals(Arrays.asList(getExpectedAlerts()).toString(),
160-
'[' + driver.findElement(By.id("myTextarea")).getAttribute("value") + ']');
156+
verifyTextArea2(driver, getExpectedAlerts());
161157
}
162158

163159
/**

src/test/java/org/htmlunit/html/HtmlPage3Test.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,10 @@ public void getInputByName() throws Exception {
195195

196196
final WebElement form = driver.findElement(By.id("form1"));
197197
final WebElement input = form.findElement(By.name("textInput1"));
198-
assertEquals("name", "textInput1", input.getAttribute("name"));
198+
assertEquals("name", "textInput1", input.getDomAttribute("name"));
199199

200-
assertEquals("value", "textInput1", input.getAttribute("value"));
201-
assertEquals("type", "text", input.getAttribute("type"));
200+
assertEquals("value", "textInput1", input.getDomAttribute("value"));
201+
assertEquals("type", "text", input.getDomAttribute("type"));
202202
}
203203

204204
/**

src/test/java/org/htmlunit/html/HtmlRadioButtonInput2Test.java

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
*/
1515
package org.htmlunit.html;
1616

17-
import java.util.Arrays;
18-
1917
import org.htmlunit.WebDriverTestCase;
2018
import org.htmlunit.junit.BrowserRunner;
2119
import org.htmlunit.junit.annotation.Alerts;
@@ -542,62 +540,56 @@ public void checkedOnXmlResponse() throws Exception {
542540
* @throws Exception if the test fails
543541
*/
544542
@Test
545-
@Alerts("foo,change,")
543+
@Alerts({"foo", "change"})
546544
public void onchangeFires() throws Exception {
547545
final String html =
548546
HtmlPageTest.STANDARDS_MODE_PREFIX_
549547
+ "<html><head><title>foo</title>\n"
550548
+ "<script>\n"
551-
+ " function debug(string) {\n"
552-
+ " document.getElementById('myTextarea').value += string + ',';\n"
553-
+ " }\n"
549+
+ LOG_TEXTAREA_FUNCTION
554550
+ "</script>\n"
555551
+ "</head><body>\n"
556552
+ "<form>\n"
557553
+ "<input type='radio' name='radioGroup' id='radio'"
558-
+ " onchange='debug(\"foo\");debug(event.type);'>Check me</input>\n"
554+
+ " onchange='log(\"foo\");log(event.type);'>Check me</input>\n"
559555
+ "</form>\n"
560-
+ "<textarea id='myTextarea'></textarea>\n"
556+
+ LOG_TEXTAREA
561557
+ "</body></html>";
562558

563559
final WebDriver driver = loadPage2(html);
564560
driver.findElement(By.id("radio")).click();
565561

566-
assertEquals(Arrays.asList(getExpectedAlerts()).toString(),
567-
'[' + driver.findElement(By.id("myTextarea")).getAttribute("value") + ']');
562+
verifyTextArea2(driver, getExpectedAlerts());
568563
}
569564

570565
/**
571566
* @throws Exception if the test fails
572567
*/
573568
@Test
574-
@Alerts("foo,change,boo,blur,")
569+
@Alerts({"foo", "change", "boo", "blur"})
575570
public void onchangeFires2() throws Exception {
576571
final String html =
577572
HtmlPageTest.STANDARDS_MODE_PREFIX_
578573
+ "<html><head><title>foo</title>\n"
579574
+ "<script>\n"
580-
+ " function debug(string) {\n"
581-
+ " document.getElementById('myTextarea').value += string + ',';\n"
582-
+ " }\n"
575+
+ LOG_TEXTAREA_FUNCTION
583576
+ "</script>\n"
584577
+ "</head><body>\n"
585578
+ "<form>\n"
586579
+ "<input type='radio' name='radioGroup' id='radio1'"
587-
+ " onChange='debug(\"foo\");debug(event.type);'"
588-
+ " onBlur='debug(\"boo\");debug(event.type);'"
580+
+ " onChange='log(\"foo\");log(event.type);'"
581+
+ " onBlur='log(\"boo\");log(event.type);'"
589582
+ ">Check Me</input>\n"
590583
+ "<input type='radio' name='radioGroup' id='radio2'>Or Check Me</input>\n"
591584
+ "</form>\n"
592-
+ "<textarea id='myTextarea'></textarea>\n"
585+
+ LOG_TEXTAREA
593586
+ "</body></html>";
594587

595588
final WebDriver driver = loadPage2(html);
596589
driver.findElement(By.id("radio1")).click();
597590
driver.findElement(By.id("radio2")).click();
598591

599-
assertEquals(Arrays.asList(getExpectedAlerts()).toString(),
600-
'[' + driver.findElement(By.id("myTextarea")).getAttribute("value") + ']');
592+
verifyTextArea2(driver, getExpectedAlerts());
601593
}
602594

603595
/**

src/test/java/org/htmlunit/html/HtmlRangeInputTest.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ public void properties() throws Exception {
324324
* @throws Exception if the test fails
325325
*/
326326
@Test
327-
@Alerts("50")
327+
@Alerts({"42", "50"})
328328
public void clearInput() throws Exception {
329329
final String html = "<html>\n"
330330
+ "<body>\n"
@@ -336,9 +336,13 @@ public void clearInput() throws Exception {
336336

337337
final WebDriver driver = loadPage2(html);
338338
final WebElement element = driver.findElement(By.id("tester"));
339-
element.clear();
340339

341-
assertEquals(getExpectedAlerts()[0], element.getAttribute("value"));
340+
assertEquals(getExpectedAlerts()[0], element.getDomAttribute("value"));
341+
assertEquals(getExpectedAlerts()[0], element.getDomProperty("value"));
342+
343+
element.clear();
344+
assertEquals(getExpectedAlerts()[0], element.getDomAttribute("value"));
345+
assertEquals(getExpectedAlerts()[1], element.getDomProperty("value"));
342346
}
343347

344348
/**

0 commit comments

Comments
 (0)