@@ -112,10 +112,12 @@ public void typeWhileDisabled() throws Exception {
112112 @ Alerts ({"null" , "null" })
113113 public void typeDoesNotChangeValueAttribute () throws Exception {
114114 final String html = "<html>\n "
115- + "<head></head>\n "
115+ + "<head>\n "
116+ + "<script>" + LOG_TITLE_FUNCTION + "</script>\n "
117+ + "</head>\n "
116118 + "<body>\n "
117119 + " <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\" ));'>"
119121 + "DoIt</button>\n "
120122 + "</body></html>" ;
121123
@@ -124,11 +126,11 @@ public void typeDoesNotChangeValueAttribute() throws Exception {
124126
125127 final WebElement check = driver .findElement (By .id ("check" ));
126128 check .click ();
127- verifyAlerts (driver , getExpectedAlerts ()[0 ]);
129+ verifyTitle2 (driver , getExpectedAlerts ()[0 ]);
128130
129131 p .sendKeys ("abc" );
130132 check .click ();
131- verifyAlerts (driver , getExpectedAlerts ()[ 1 ] );
133+ verifyTitle2 (driver , getExpectedAlerts ());
132134 }
133135
134136 /**
@@ -138,10 +140,12 @@ public void typeDoesNotChangeValueAttribute() throws Exception {
138140 @ Alerts ({"HtmlUnit" , "HtmlUnit" })
139141 public void typeDoesNotChangeValueAttributeWithInitialValue () throws Exception {
140142 final String html = "<html>\n "
141- + "<head></head>\n "
143+ + "<head>\n "
144+ + "<script>" + LOG_TITLE_FUNCTION + "</script>\n "
145+ + "</head>\n "
142146 + "<body>\n "
143147 + " <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\" ));'>"
145149 + "DoIt</button>\n "
146150 + "</body></html>" ;
147151
@@ -150,11 +154,11 @@ public void typeDoesNotChangeValueAttributeWithInitialValue() throws Exception {
150154
151155 final WebElement check = driver .findElement (By .id ("check" ));
152156 check .click ();
153- verifyAlerts (driver , getExpectedAlerts ()[0 ]);
157+ verifyTitle2 (driver , getExpectedAlerts ()[0 ]);
154158
155159 p .sendKeys ("abc" );
156160 check .click ();
157- verifyAlerts (driver , getExpectedAlerts ()[ 1 ] );
161+ verifyTitle2 (driver , getExpectedAlerts ());
158162 }
159163
160164 /**
@@ -215,12 +219,16 @@ public void preventDefault_OnKeyPress() throws Exception {
215219 * @throws Exception if an error occurs
216220 */
217221 @ Test
222+ @ Alerts ({"foo" , "change" , "boo" , "blur" , "boo" , "blur" })
218223 public void typeOnChange () throws Exception {
219224 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 "
221229 + "<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 "
224232 + "<button id='b'>some button</button>\n "
225233 + "</body></html>" ;
226234
@@ -232,17 +240,16 @@ public void typeOnChange() throws Exception {
232240
233241 // trigger lost focus
234242 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 ] );
237245
238246 // set only the focus but change nothing
239247 p .click ();
240248 assertTrue (getCollectedAlerts (driver , 1 ).isEmpty ());
241249
242250 // trigger lost focus
243251 driver .findElement (By .id ("b" )).click ();
244- final String [] expectedAlerts2 = {"boo" , "blur" };
245- assertEquals (expectedAlerts2 , getCollectedAlerts (driver , 2 ));
252+ verifyTitle2 (driver , getExpectedAlerts ());
246253 }
247254
248255 /**
@@ -252,10 +259,12 @@ public void typeOnChange() throws Exception {
252259 public void setValueOnChange () throws Exception {
253260 final String html =
254261 "<html>\n "
255- + "<head></head>\n "
262+ + "<head>\n "
263+ + "<script>" + LOG_TITLE_FUNCTION + "</script>\n "
264+ + "</head>\n "
256265 + "<body>\n "
257266 + " <input type='password' id='p' value='Hello world'"
258- + " onChange='alert (\" foo\" );alert (event.type);'>\n "
267+ + " onChange='log (\" foo\" );log (event.type);'>\n "
259268 + " <button id='b'>some button</button>\n "
260269 + " <button id='set' onclick='document.getElementById(\" p\" ).value=\" HtmlUnit\" '>setValue</button>\n "
261270 + "</body></html>" ;
@@ -280,7 +289,7 @@ public void setDefaultValueOnChange() throws Exception {
280289 + "<head></head>\n "
281290 + "<body>\n "
282291 + " <input type='password' id='p' value='Hello world'"
283- + " onChange='alert (\" foo\" );alert (event.type);'>\n "
292+ + " onChange='log (\" foo\" );log (event.type);'>\n "
284293 + " <button id='b'>some button</button>\n "
285294 + " <button id='set' onclick='document.getElementById(\" p\" ).defaultValue=\" HtmlUnit\" '>"
286295 + "setValue</button>\n "
@@ -289,11 +298,11 @@ public void setDefaultValueOnChange() throws Exception {
289298 final WebDriver driver = loadPage2 (html );
290299 driver .findElement (By .id ("set" )).click ();
291300
292- assertEquals ( Collections . emptyList (), getCollectedAlerts ( driver ) );
301+ verifyTitle2 ( driver );
293302
294303 // trigger lost focus
295304 driver .findElement (By .id ("b" )).click ();
296- assertEquals ( Collections . emptyList (), getCollectedAlerts ( driver ) );
305+ verifyTitle2 ( driver );
297306 }
298307
299308 /**
0 commit comments