@@ -87,17 +87,15 @@ public void fireEvent_initFromTemplate() throws Exception {
8787 * @throws Exception if the test fails
8888 */
8989 @ Test
90- @ Alerts ("mousedown span,mouseup span,click span,mousedown text,focus text,mouseup text,"
91- + "click text,mousedown image,focus image,mouseup image,click image,mousedown textarea,focus textarea,"
92- + "mouseup textarea,click textarea," )
90+ @ Alerts ({"mousedown span" , "mouseup span" , "click span" ,
91+ "mousedown text" , "focus text" , "mouseup text" , "click text" ,
92+ "mousedown image" , "focus image" , "mouseup image" , "click image" ,
93+ "mousedown textarea" , "focus textarea" , "mouseup textarea" , "click textarea" })
9394 public void clickEvents () throws Exception {
9495 final String html = "<html>\n "
9596 + "<head>\n "
9697 + " <script>\n "
97- + " function log(text) {\n "
98- + " var textarea = document.getElementById('myTextarea');\n "
99- + " textarea.value += text + ',';\n "
100- + " }\n "
98+ + LOG_TEXTAREA_FUNCTION
10199 + " </script>\n "
102100 + "</head><body>\n "
103101 + " <span id='testSpan' onfocus=\" log('will not be triggered')\" onmousedown=\" log('mousedown span')\" "
@@ -112,31 +110,28 @@ public void clickEvents() throws Exception {
112110 + " onmousedown=\" log('mousedown textarea')\" onclick=\" log('click textarea')\" "
113111 + " onmouseup=\" log('mouseup textarea')\" onfocus=\" log('focus textarea')\" ></textarea>\n "
114112 + " </form>\n "
115- + " <textarea id='myTextarea' cols='80' rows='10'></textarea> \n "
113+ + LOG_TEXTAREA
116114 + "</body></html>" ;
117115
118116 final WebDriver driver = loadPage2 (html );
119117 driver .findElement (By .id ("testSpan" )).click ();
120118 driver .findElement (By .id ("testInput" )).click ();
121119 driver .findElement (By .id ("testImage" )).click ();
122120 driver .findElement (By .id ("testTextarea" )).click ();
123- final String expected = getExpectedAlerts ()[ 0 ];
124- assertEquals ( expected , driver . findElement ( By . id ( "myTextarea" )). getAttribute ( "value" ));
121+
122+ verifyTextArea2 ( driver , getExpectedAlerts ( ));
125123 }
126124
127125 /**
128126 * @throws Exception if the test fails
129127 */
130128 @ Test
131- @ Alerts ("mousedown label, mouseup label, click label, focus text, click text," )
129+ @ Alerts ({ "mousedown label" , " mouseup label" , " click label" , " focus text" , " click text" } )
132130 public void clickEventsLabel () throws Exception {
133131 final String html = "<html>\n "
134132 + "<head>\n "
135133 + " <script>\n "
136- + " function log(text) {\n "
137- + " var textarea = document.getElementById('myTextarea');\n "
138- + " textarea.value += text + ',';\n "
139- + " }\n "
134+ + LOG_TEXTAREA_FUNCTION
140135 + " </script>\n "
141136 + "</head><body>\n "
142137 + " <label id='testLabel' for='testInput'"
@@ -146,37 +141,34 @@ public void clickEventsLabel() throws Exception {
146141 + " <input type='text' id='testInput' onmousedown=\" log('mousedown text')\" "
147142 + " onclick=\" log('click text')\" onmouseup=\" log('mouseup text')\" onfocus=\" log('focus text')\" >\n "
148143 + " </form>\n "
149- + " <textarea id='myTextarea' cols='80' rows='10'></textarea> \n "
144+ + LOG_TEXTAREA
150145 + "</body></html>" ;
151146
152147 final WebDriver driver = loadPage2 (html );
153148 driver .findElement (By .id ("testLabel" )).click ();
154149
155- final String expected = getExpectedAlerts ()[0 ];
156- assertEquals (expected , driver .findElement (By .id ("myTextarea" )).getAttribute ("value" ));
150+ verifyTextArea2 (driver , getExpectedAlerts ());
157151 }
158152
159153 /**
160154 * Test event order.
161155 * @throws Exception if the test fails
162156 */
163157 @ Test
158+ @ Alerts ({"focus" , "keydown" , "keypress" , "keyup" , "change" , "blur" })
164159 public void eventOrder () throws Exception {
165160 final String html = "<html>\n "
166161 + "<head>\n "
167162 + " <script>\n "
168- + " function log(text) {\n "
169- + " var textarea = document.getElementById('myTextarea');\n "
170- + " textarea.value += text + ',';\n "
171- + " }\n "
163+ + LOG_TEXTAREA_FUNCTION
172164 + " </script>\n "
173165 + "</head><body>\n "
174166 + "<form>\n "
175167 + " <input name='foo' id='foo' onfocus=\" log('focus')\" onblur=\" log('blur')\" onchange=\" log('change')\" "
176168 + " onkeydown=\" log('keydown')\" onkeypress=\" log('keypress')\" onkeyup=\" log('keyup')\" >\n "
177169 + " <input name='other' id='other'>\n "
178170 + "</form>\n "
179- + " <textarea id='myTextarea' cols='80'></textarea> \n "
171+ + LOG_TEXTAREA
180172 + "</body></html>" ;
181173
182174 final WebDriver webDriver = loadPage2 (html );
@@ -185,7 +177,6 @@ public void eventOrder() throws Exception {
185177 textField .sendKeys ("a" );
186178 webDriver .findElement (By .id ("other" )).click ();
187179
188- final String expected = "focus,keydown,keypress,keyup,change,blur," ;
189- assertEquals (expected , webDriver .findElement (By .id ("myTextarea" )).getAttribute ("value" ));
180+ verifyTextArea2 (webDriver , getExpectedAlerts ());
190181 }
191182}
0 commit comments