@@ -112,10 +112,12 @@ public void typeWhileDisabled() throws Exception {
112
112
@ Alerts ({"null" , "null" })
113
113
public void typeDoesNotChangeValueAttribute () throws Exception {
114
114
final String html = "<html>\n "
115
- + "<head></head>\n "
115
+ + "<head>\n "
116
+ + "<script>" + LOG_TITLE_FUNCTION + "</script>\n "
117
+ + "</head>\n "
116
118
+ "<body>\n "
117
119
+ " <input type='password' id='p'/>\n "
118
- + " <button id='check' onclick='alert (document.getElementById(\" p\" ).getAttribute(\" value\" ));'>"
120
+ + " <button id='check' onclick='log (document.getElementById(\" p\" ).getAttribute(\" value\" ));'>"
119
121
+ "DoIt</button>\n "
120
122
+ "</body></html>" ;
121
123
@@ -124,11 +126,11 @@ public void typeDoesNotChangeValueAttribute() throws Exception {
124
126
125
127
final WebElement check = driver .findElement (By .id ("check" ));
126
128
check .click ();
127
- verifyAlerts (driver , getExpectedAlerts ()[0 ]);
129
+ verifyTitle2 (driver , getExpectedAlerts ()[0 ]);
128
130
129
131
p .sendKeys ("abc" );
130
132
check .click ();
131
- verifyAlerts (driver , getExpectedAlerts ()[ 1 ] );
133
+ verifyTitle2 (driver , getExpectedAlerts ());
132
134
}
133
135
134
136
/**
@@ -138,10 +140,12 @@ public void typeDoesNotChangeValueAttribute() throws Exception {
138
140
@ Alerts ({"HtmlUnit" , "HtmlUnit" })
139
141
public void typeDoesNotChangeValueAttributeWithInitialValue () throws Exception {
140
142
final String html = "<html>\n "
141
- + "<head></head>\n "
143
+ + "<head>\n "
144
+ + "<script>" + LOG_TITLE_FUNCTION + "</script>\n "
145
+ + "</head>\n "
142
146
+ "<body>\n "
143
147
+ " <input type='password' id='p' value='HtmlUnit'/>\n "
144
- + " <button id='check' onclick='alert (document.getElementById(\" p\" ).getAttribute(\" value\" ));'>"
148
+ + " <button id='check' onclick='log (document.getElementById(\" p\" ).getAttribute(\" value\" ));'>"
145
149
+ "DoIt</button>\n "
146
150
+ "</body></html>" ;
147
151
@@ -150,11 +154,11 @@ public void typeDoesNotChangeValueAttributeWithInitialValue() throws Exception {
150
154
151
155
final WebElement check = driver .findElement (By .id ("check" ));
152
156
check .click ();
153
- verifyAlerts (driver , getExpectedAlerts ()[0 ]);
157
+ verifyTitle2 (driver , getExpectedAlerts ()[0 ]);
154
158
155
159
p .sendKeys ("abc" );
156
160
check .click ();
157
- verifyAlerts (driver , getExpectedAlerts ()[ 1 ] );
161
+ verifyTitle2 (driver , getExpectedAlerts ());
158
162
}
159
163
160
164
/**
@@ -215,12 +219,16 @@ public void preventDefault_OnKeyPress() throws Exception {
215
219
* @throws Exception if an error occurs
216
220
*/
217
221
@ Test
222
+ @ Alerts ({"foo" , "change" , "boo" , "blur" , "boo" , "blur" })
218
223
public void typeOnChange () throws Exception {
219
224
final String html =
220
- "<html><head></head><body>\n "
225
+ "<html><head>\n "
226
+ + "<script>" + LOG_TITLE_FUNCTION + "</script>\n "
227
+ + "</head>\n "
228
+ + "<body>\n "
221
229
+ "<input type='password' id='p' value='Hello world'"
222
- + " onChange='alert (\" foo\" );alert (event.type);'"
223
- + " onBlur='alert (\" boo\" );alert (event.type);'>\n "
230
+ + " onChange='log (\" foo\" );log (event.type);'"
231
+ + " onBlur='log (\" boo\" );log (event.type);'>\n "
224
232
+ "<button id='b'>some button</button>\n "
225
233
+ "</body></html>" ;
226
234
@@ -232,17 +240,16 @@ public void typeOnChange() throws Exception {
232
240
233
241
// trigger lost focus
234
242
driver .findElement (By .id ("b" )).click ();
235
- final String [] expectedAlerts1 = { "foo" , "change" , "boo" , "blur" };
236
- assertEquals ( expectedAlerts1 , getCollectedAlerts ( driver , 4 ) );
243
+ verifyTitle2 ( driver , getExpectedAlerts ()[ 0 ], getExpectedAlerts ()[ 1 ],
244
+ getExpectedAlerts ()[ 2 ], getExpectedAlerts ()[ 3 ] );
237
245
238
246
// set only the focus but change nothing
239
247
p .click ();
240
248
assertTrue (getCollectedAlerts (driver , 1 ).isEmpty ());
241
249
242
250
// trigger lost focus
243
251
driver .findElement (By .id ("b" )).click ();
244
- final String [] expectedAlerts2 = {"boo" , "blur" };
245
- assertEquals (expectedAlerts2 , getCollectedAlerts (driver , 2 ));
252
+ verifyTitle2 (driver , getExpectedAlerts ());
246
253
}
247
254
248
255
/**
@@ -252,10 +259,12 @@ public void typeOnChange() throws Exception {
252
259
public void setValueOnChange () throws Exception {
253
260
final String html =
254
261
"<html>\n "
255
- + "<head></head>\n "
262
+ + "<head>\n "
263
+ + "<script>" + LOG_TITLE_FUNCTION + "</script>\n "
264
+ + "</head>\n "
256
265
+ "<body>\n "
257
266
+ " <input type='password' id='p' value='Hello world'"
258
- + " onChange='alert (\" foo\" );alert (event.type);'>\n "
267
+ + " onChange='log (\" foo\" );log (event.type);'>\n "
259
268
+ " <button id='b'>some button</button>\n "
260
269
+ " <button id='set' onclick='document.getElementById(\" p\" ).value=\" HtmlUnit\" '>setValue</button>\n "
261
270
+ "</body></html>" ;
@@ -280,7 +289,7 @@ public void setDefaultValueOnChange() throws Exception {
280
289
+ "<head></head>\n "
281
290
+ "<body>\n "
282
291
+ " <input type='password' id='p' value='Hello world'"
283
- + " onChange='alert (\" foo\" );alert (event.type);'>\n "
292
+ + " onChange='log (\" foo\" );log (event.type);'>\n "
284
293
+ " <button id='b'>some button</button>\n "
285
294
+ " <button id='set' onclick='document.getElementById(\" p\" ).defaultValue=\" HtmlUnit\" '>"
286
295
+ "setValue</button>\n "
@@ -289,11 +298,11 @@ public void setDefaultValueOnChange() throws Exception {
289
298
final WebDriver driver = loadPage2 (html );
290
299
driver .findElement (By .id ("set" )).click ();
291
300
292
- assertEquals ( Collections . emptyList (), getCollectedAlerts ( driver ) );
301
+ verifyTitle2 ( driver );
293
302
294
303
// trigger lost focus
295
304
driver .findElement (By .id ("b" )).click ();
296
- assertEquals ( Collections . emptyList (), getCollectedAlerts ( driver ) );
305
+ verifyTitle2 ( driver );
297
306
}
298
307
299
308
/**
0 commit comments