View Javadoc
1   /*
2    * Copyright (c) 2002-2025 Gargoyle Software Inc.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * https://www.apache.org/licenses/LICENSE-2.0
8    *
9    * Unless required by applicable law or agreed to in writing, software
10   * distributed under the License is distributed on an "AS IS" BASIS,
11   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12   * See the License for the specific language governing permissions and
13   * limitations under the License.
14   */
15  package org.htmlunit.html.serializer;
16  
17  import org.htmlunit.WebDriverTestCase;
18  import org.htmlunit.junit.BrowserRunner;
19  import org.htmlunit.junit.annotation.Alerts;
20  import org.htmlunit.junit.annotation.HtmlUnitNYI;
21  import org.junit.Test;
22  import org.junit.runner.RunWith;
23  import org.openqa.selenium.By;
24  import org.openqa.selenium.JavascriptExecutor;
25  import org.openqa.selenium.WebDriver;
26  import org.openqa.selenium.WebElement;
27  
28  /**
29   * Tests for {@link HtmlSerializerVisibleText}.
30   * This contains the tests for plain controls.
31   *
32   * @author Ronald Brill
33   */
34  @RunWith(BrowserRunner.class)
35  public class HtmlSerializerInnerOuterText2Test extends WebDriverTestCase {
36  
37      /**
38       * Verifies getInnerText().
39       * @throws Exception if the test fails
40       */
41      @Test
42      @Alerts("")
43      public void getInnerTextWhiteSpaceBreak() throws Exception {
44          getInnerTextWhiteSpaceBreak(null);
45      }
46  
47      /**
48       * Verifies getInnerText().
49       * @throws Exception if the test fails
50       */
51      @Test
52      @Alerts("")
53      public void getInnerTextWhiteSpaceBreakNormal() throws Exception {
54          getInnerTextWhiteSpaceBreak("normal");
55      }
56  
57      /**
58       * Verifies getInnerText().
59       * @throws Exception if the test fails
60       */
61      @Test
62      @Alerts("")
63      public void getInnerTextWhiteSpaceBreakNowrap() throws Exception {
64          getInnerTextWhiteSpaceBreak("nowrap");
65      }
66  
67      /**
68       * Verifies getInnerText().
69       * @throws Exception if the test fails
70       */
71      @Test
72      @Alerts("")
73      public void getInnerTextWhiteSpaceBreakPre() throws Exception {
74          getInnerTextWhiteSpaceBreak("pre");
75      }
76  
77      /**
78       * Verifies getInnerText().
79       * @throws Exception if the test fails
80       */
81      @Test
82      @Alerts("")
83      public void getInnerTextWhiteSpaceBreakPreWrap() throws Exception {
84          getInnerTextWhiteSpaceBreak("pre-wrap");
85      }
86  
87      /**
88       * Verifies getInnerText().
89       * @throws Exception if the test fails
90       */
91      @Test
92      @Alerts("")
93      public void getInnerTextWhiteSpaceBreakPreLine() throws Exception {
94          getInnerTextWhiteSpaceBreak("pre-line");
95      }
96  
97      private void getInnerTextWhiteSpaceBreak(final String whiteSpace) throws Exception {
98          final String htmlContent = DOCTYPE_HTML
99              + "<html>\n"
100             + "<head></head>\n"
101             + "<body>\n"
102             + "  <br id='tester' " + (whiteSpace == null ? "" : ("style='white-space: " + whiteSpace + "'")) + ">\n"
103             + "</body></html>";
104 
105         final WebDriver driver = loadPage2(htmlContent);
106         final String text = (String) ((JavascriptExecutor) driver)
107                 .executeScript("return document.getElementById('tester').innerText");
108         assertEquals(getExpectedAlerts()[0], text);
109     }
110 
111     /**
112      * Verifies getInnerText().
113      * @throws Exception if the test fails
114      */
115     @Test
116     @Alerts("")
117     public void getInnerTextWhiteSpaceInputHidden() throws Exception {
118         getInnerTextWhiteSpaceInputHidden(null);
119     }
120 
121     /**
122      * Verifies getInnerText().
123      * @throws Exception if the test fails
124      */
125     @Test
126     @Alerts("")
127     public void getInnerTextWhiteSpaceInputHiddenNormal() throws Exception {
128         getInnerTextWhiteSpaceInputHidden("normal");
129     }
130 
131     /**
132      * Verifies getInnerText().
133      * @throws Exception if the test fails
134      */
135     @Test
136     @Alerts("")
137     public void getInnerTextWhiteSpaceInputHiddenNowrap() throws Exception {
138         getInnerTextWhiteSpaceInputHidden("nowrap");
139     }
140 
141     /**
142      * Verifies getInnerText().
143      * @throws Exception if the test fails
144      */
145     @Test
146     @Alerts("")
147     public void getInnerTextWhiteSpaceInputHiddenPre() throws Exception {
148         getInnerTextWhiteSpaceInputHidden("pre");
149     }
150 
151     /**
152      * Verifies getInnerText().
153      * @throws Exception if the test fails
154      */
155     @Test
156     @Alerts("")
157     public void getInnerTextWhiteSpaceInputHiddenPreWrap() throws Exception {
158         getInnerTextWhiteSpaceInputHidden("pre-wrap");
159     }
160 
161     /**
162      * Verifies getInnerText().
163      * @throws Exception if the test fails
164      */
165     @Test
166     @Alerts("")
167     public void getInnerTextWhiteSpaceInputHiddenPreLine() throws Exception {
168         getInnerTextWhiteSpaceInputHidden("pre-line");
169     }
170 
171     private void getInnerTextWhiteSpaceInputHidden(final String whiteSpace) throws Exception {
172         final String htmlContent = DOCTYPE_HTML
173             + "<html>\n"
174             + "<head></head>\n"
175             + "<body>\n"
176             + "<form id='form1'>\n"
177             + "  <input type='hidden' name='tester' id='tester' "
178                         + (whiteSpace == null ? "" : ("style='white-space: " + whiteSpace + "'"))
179                         + " value='  A B  C\t \t  D \r\nEF\nG \n H  <br> I  '>\n"
180             + "</form>\n"
181             + "</body></html>";
182 
183         final WebDriver driver = loadPage2(htmlContent);
184         final String text = (String) ((JavascriptExecutor) driver)
185                 .executeScript("return document.getElementById('tester').innerText");
186         assertEquals(getExpectedAlerts()[0], text);
187     }
188 
189     /**
190      * Verifies getInnerText().
191      * @throws Exception if the test fails
192      */
193     @Test
194     @Alerts("var x;  \n \t   \n var y;")
195     public void getInnerTextWhiteSpaceScript() throws Exception {
196         getInnerTextWhiteSpaceScript(null);
197     }
198 
199     /**
200      * Verifies getInnerText().
201      * @throws Exception if the test fails
202      */
203     @Test
204     @Alerts("var x;  \n \t   \n var y;")
205     public void getInnerTextWhiteSpaceScriptNormal() throws Exception {
206         getInnerTextWhiteSpaceScript("normal");
207     }
208 
209     /**
210      * Verifies getInnerText().
211      * @throws Exception if the test fails
212      */
213     @Test
214     @Alerts("var x;  \n \t   \n var y;")
215     public void getInnerTextWhiteSpaceScriptNowrap() throws Exception {
216         getInnerTextWhiteSpaceScript("nowrap");
217     }
218 
219     /**
220      * Verifies getInnerText().
221      * @throws Exception if the test fails
222      */
223     @Test
224     @Alerts("var x;  \n \t   \n var y;")
225     public void getInnerTextWhiteSpaceScriptPre() throws Exception {
226         getInnerTextWhiteSpaceScript("pre");
227     }
228 
229     /**
230      * Verifies getInnerText().
231      * @throws Exception if the test fails
232      */
233     @Test
234     @Alerts("var x;  \n \t   \n var y;")
235     public void getInnerTextWhiteSpaceScriptPreWrap() throws Exception {
236         getInnerTextWhiteSpaceScript("pre-wrap");
237     }
238 
239     /**
240      * Verifies getInnerText().
241      * @throws Exception if the test fails
242      */
243     @Test
244     @Alerts("var x;  \n \t   \n var y;")
245     public void getInnerTextWhiteSpaceScriptPreLine() throws Exception {
246         getInnerTextWhiteSpaceScript("pre-line");
247     }
248 
249     private void getInnerTextWhiteSpaceScript(final String whiteSpace) throws Exception {
250         final String htmlContent = DOCTYPE_HTML
251             + "<html>\n"
252             + "<head></head>\n"
253             + "<body>\n"
254             + "  <script id='tester' " + (whiteSpace == null ? "" : ("style='white-space: " + whiteSpace + "'")) + ">"
255                 + "var x;  \n \t   \r\n var y;</script>\n"
256             + "</body></html>";
257 
258         final WebDriver driver = loadPage2(htmlContent);
259         final String text = (String) ((JavascriptExecutor) driver)
260                 .executeScript("return document.getElementById('tester').innerText");
261         assertEquals(getExpectedAlerts()[0], text);
262     }
263 
264     /**
265      * Verifies getInnerText().
266      * @throws Exception if the test fails
267      */
268     @Test
269     @Alerts("  A B  C\t \t  D \nEF\nG \n H  <br> I  ")
270     public void getInnerTextWhiteSpaceStyle() throws Exception {
271         getInnerTextWhiteSpaceStyle(null);
272     }
273 
274     /**
275      * Verifies getInnerText().
276      * @throws Exception if the test fails
277      */
278     @Test
279     @Alerts("  A B  C\t \t  D \nEF\nG \n H  <br> I  ")
280     public void getInnerTextWhiteSpaceStyleNormal() throws Exception {
281         getInnerTextWhiteSpaceStyle("normal");
282     }
283 
284     /**
285      * Verifies getInnerText().
286      * @throws Exception if the test fails
287      */
288     @Test
289     @Alerts("  A B  C\t \t  D \nEF\nG \n H  <br> I  ")
290     public void getInnerTextWhiteSpaceStyleNowrap() throws Exception {
291         getInnerTextWhiteSpaceStyle("nowrap");
292     }
293 
294     /**
295      * Verifies getInnerText().
296      * @throws Exception if the test fails
297      */
298     @Test
299     @Alerts("  A B  C\t \t  D \nEF\nG \n H  <br> I  ")
300     public void getInnerTextWhiteSpaceStylePre() throws Exception {
301         getInnerTextWhiteSpaceStyle("pre");
302     }
303 
304     /**
305      * Verifies getInnerText().
306      * @throws Exception if the test fails
307      */
308     @Test
309     @Alerts("  A B  C\t \t  D \nEF\nG \n H  <br> I  ")
310     public void getInnerTextWhiteSpaceStylePreWrap() throws Exception {
311         getInnerTextWhiteSpaceStyle("pre-wrap");
312     }
313 
314     /**
315      * Verifies getInnerText().
316      * @throws Exception if the test fails
317      */
318     @Test
319     @Alerts("  A B  C\t \t  D \nEF\nG \n H  <br> I  ")
320     public void getInnerTextWhiteSpaceStylePreLine() throws Exception {
321         getInnerTextWhiteSpaceStyle("pre-line");
322     }
323 
324     private void getInnerTextWhiteSpaceStyle(final String whiteSpace) throws Exception {
325         final String htmlContent = DOCTYPE_HTML
326             + "<html>\n"
327             + "<head></head>\n"
328             + "<body>\n"
329             + "  <style id='tester' " + (whiteSpace == null ? "" : ("style='white-space: " + whiteSpace + "'")) + ">"
330                 + "  A B  C\t \t  D \r\nEF\nG \n H  <br> I  </style>\n"
331             + "</body></html>";
332 
333         final WebDriver driver = loadPage2(htmlContent);
334         final String text = (String) ((JavascriptExecutor) driver)
335                 .executeScript("return document.getElementById('tester').innerText");
336         assertEquals(getExpectedAlerts()[0], text);
337     }
338 
339     /**
340      * Verifies getInnerText().
341      * @throws Exception if the test fails
342      */
343     @Test
344     @Alerts("  A B  C\t \t  D \nEF\nG \n H  <br> I  ")
345     public void getInnerTextWhiteSpaceNoframes() throws Exception {
346         getInnerTextWhiteSpaceNoframes(null);
347     }
348 
349     /**
350      * Verifies getInnerText().
351      * @throws Exception if the test fails
352      */
353     @Test
354     @Alerts("  A B  C\t \t  D \nEF\nG \n H  <br> I  ")
355     public void getInnerTextWhiteSpaceNoframesNormal() throws Exception {
356         getInnerTextWhiteSpaceNoframes("normal");
357     }
358 
359     /**
360      * Verifies getInnerText().
361      * @throws Exception if the test fails
362      */
363     @Test
364     @Alerts("  A B  C\t \t  D \nEF\nG \n H  <br> I  ")
365     public void getInnerTextWhiteSpaceNoframesNowrap() throws Exception {
366         getInnerTextWhiteSpaceNoframes("nowrap");
367     }
368 
369     /**
370      * Verifies getInnerText().
371      * @throws Exception if the test fails
372      */
373     @Test
374     @Alerts("  A B  C\t \t  D \nEF\nG \n H  <br> I  ")
375     public void getInnerTextWhiteSpaceNoframesPre() throws Exception {
376         getInnerTextWhiteSpaceNoframes("pre");
377     }
378 
379     /**
380      * Verifies getInnerText().
381      * @throws Exception if the test fails
382      */
383     @Test
384     @Alerts("  A B  C\t \t  D \nEF\nG \n H  <br> I  ")
385     public void getInnerTextWhiteSpaceNoframesPreWrap() throws Exception {
386         getInnerTextWhiteSpaceNoframes("pre-wrap");
387     }
388 
389     /**
390      * Verifies getInnerText().
391      * @throws Exception if the test fails
392      */
393     @Test
394     @Alerts("  A B  C\t \t  D \nEF\nG \n H  <br> I  ")
395     public void getInnerTextWhiteSpaceNoframesPreLine() throws Exception {
396         getInnerTextWhiteSpaceNoframes("pre-line");
397     }
398 
399     private void getInnerTextWhiteSpaceNoframes(final String whiteSpace) throws Exception {
400         final String htmlContent = DOCTYPE_HTML
401             + "<html>\n"
402             + "<head></head>\n"
403             + "<body>\n"
404             + "  <noframes id='tester' " + (whiteSpace == null ? "" : ("style='white-space: " + whiteSpace + "'")) + ">"
405                 + "  A B  C\t \t  D \r\nEF\nG \n H  <br> I  </noframes>\n"
406             + "</body></html>";
407 
408         final WebDriver driver = loadPage2(htmlContent);
409         final String text = (String) ((JavascriptExecutor) driver)
410                 .executeScript("return document.getElementById('tester').innerText");
411         assertEquals(getExpectedAlerts()[0], text);
412     }
413 
414     /**
415      * Verifies getInnerText().
416      * @throws Exception if the test fails
417      */
418     @Test
419     @Alerts("A B C D EF G H\nI")
420     public void getInnerTextWhiteSpaceDiv() throws Exception {
421         getInnerTextWhiteSpaceDiv(null);
422     }
423 
424     /**
425      * Verifies getInnerText().
426      * @throws Exception if the test fails
427      */
428     @Test
429     @Alerts("A B C D EF G H\nI")
430     public void getInnerTextWhiteSpaceDivNormal() throws Exception {
431         getInnerTextWhiteSpaceDiv("normal");
432     }
433 
434     /**
435      * Verifies getInnerText().
436      * @throws Exception if the test fails
437      */
438     @Test
439     @Alerts("A B C D EF G H\nI")
440     public void getInnerTextWhiteSpaceDivNowrap() throws Exception {
441         getInnerTextWhiteSpaceDiv("nowrap");
442     }
443 
444     /**
445      * Verifies getInnerText().
446      * @throws Exception if the test fails
447      */
448     @Test
449     @Alerts("  A B  C\t \t  D \nEF\nG \n H  \n I  ")
450     public void getInnerTextWhiteSpaceDivPre() throws Exception {
451         getInnerTextWhiteSpaceDiv("pre");
452     }
453 
454     /**
455      * Verifies getInnerText().
456      * @throws Exception if the test fails
457      */
458     @Test
459     @Alerts("  A B  C\t \t  D \nEF\nG \n H  \n I  ")
460     public void getInnerTextWhiteSpaceDivPreWrap() throws Exception {
461         getInnerTextWhiteSpaceDiv("pre-wrap");
462     }
463 
464     /**
465      * Verifies getInnerText().
466      * @throws Exception if the test fails
467      */
468     @Test
469     @Alerts(DEFAULT = "A B C D\nEF\nG\nH\nI",
470             FF_ESR = "A B C D\nEFGH\nI")
471     @HtmlUnitNYI(CHROME = "A B C D\nEF\nG\nH\n I",
472             EDGE = "A B C D\nEF\nG\nH\n I",
473             FF = "A B C D\nEF\nG\nH\n I",
474             FF_ESR = "A B C D\nEF\nG\nH\n I")
475     public void getInnerTextWhiteSpaceDivPreLine() throws Exception {
476         getInnerTextWhiteSpaceDiv("pre-line");
477     }
478 
479     private void getInnerTextWhiteSpaceDiv(final String whiteSpace) throws Exception {
480         final String htmlContent = DOCTYPE_HTML
481             + "<html>\n"
482             + "<head></head>\n"
483             + "<body>\n"
484             + "  <div id='tester' " + (whiteSpace == null ? "" : ("style='white-space: " + whiteSpace + "'")) + ">"
485                 + "  A B  C\t \t  D \r\nEF\nG \n H  <br> I  </div>\n"
486             + "</body></html>";
487 
488         final WebDriver driver = loadPage2(htmlContent);
489         final String text = (String) ((JavascriptExecutor) driver)
490                 .executeScript("return document.getElementById('tester').innerText");
491         assertEquals(getExpectedAlerts()[0], text);
492     }
493 
494     /**
495      * Verifies getInnerText().
496      * @throws Exception if the test fails
497      */
498     @Test
499     @Alerts("  A B  C\t \t  D \nEF\nG \n H  \n I  ")
500     @HtmlUnitNYI(CHROME = "A B C D EF G H\nI",
501             EDGE = "A B C D EF G H\nI",
502             FF = "A B C D EF G H\nI",
503             FF_ESR = "A B C D EF G H\nI")
504     public void getInnerTextWhiteSpacePre() throws Exception {
505         getInnerTextWhiteSpacePre(null);
506     }
507 
508     /**
509      * Verifies getInnerText().
510      * @throws Exception if the test fails
511      */
512     @Test
513     @Alerts("A B C D EF G H\nI")
514     public void getInnerTextWhiteSpacePreNormal() throws Exception {
515         getInnerTextWhiteSpacePre("normal");
516     }
517 
518     /**
519      * Verifies getInnerText().
520      * @throws Exception if the test fails
521      */
522     @Test
523     @Alerts("A B C D EF G H\nI")
524     public void getInnerTextWhiteSpacePreNowrap() throws Exception {
525         getInnerTextWhiteSpacePre("nowrap");
526     }
527 
528     /**
529      * Verifies getInnerText().
530      * @throws Exception if the test fails
531      */
532     @Test
533     @Alerts("  A B  C\t \t  D \nEF\nG \n H  \n I  ")
534     public void getInnerTextWhiteSpacePrePre() throws Exception {
535         getInnerTextWhiteSpacePre("pre");
536     }
537 
538     /**
539      * Verifies getInnerText().
540      * @throws Exception if the test fails
541      */
542     @Test
543     @Alerts("  A B  C\t \t  D \nEF\nG \n H  \n I  ")
544     public void getInnerTextWhiteSpacePrePreWrap() throws Exception {
545         getInnerTextWhiteSpacePre("pre-wrap");
546     }
547 
548     /**
549      * Verifies getInnerText().
550      * @throws Exception if the test fails
551      */
552     @Test
553     @Alerts(DEFAULT = "A B C D\nEF\nG\nH\nI",
554             FF_ESR = "A B C D\nEFGH\nI")
555     @HtmlUnitNYI(CHROME = "A B C D\nEF\nG\nH\n I",
556             EDGE = "A B C D\nEF\nG\nH\n I",
557             FF = "A B C D\nEF\nG\nH\n I",
558             FF_ESR = "A B C D\nEF\nG\nH\n I")
559     public void getInnerTextWhiteSpacePrePreLine() throws Exception {
560         getInnerTextWhiteSpacePre("pre-line");
561     }
562 
563     private void getInnerTextWhiteSpacePre(final String whiteSpace) throws Exception {
564         final String htmlContent = DOCTYPE_HTML
565             + "<html>\n"
566             + "<head></head>\n"
567             + "<body>\n"
568             + "  <pre id='tester' " + (whiteSpace == null ? "" : ("style='white-space: " + whiteSpace + "'")) + ">"
569                     + "  A B  C\t \t  D \r\nEF\nG \n H  <br> I  </pre>\n"
570             + "</body></html>";
571 
572         final WebDriver driver = loadPage2(htmlContent);
573         final String text = (String) ((JavascriptExecutor) driver)
574                 .executeScript("return document.getElementById('tester').innerText");
575         assertEquals(getExpectedAlerts()[0], text);
576     }
577 
578     /**
579      * Verifies getInnerText().
580      * @throws Exception if the test fails
581      */
582     @Test
583     @Alerts("")
584     public void getInnerTextWhiteSpaceTextArea() throws Exception {
585         getInnerTextWhiteSpaceTextArea(null);
586     }
587 
588     /**
589      * Verifies getInnerText().
590      * @throws Exception if the test fails
591      */
592     @Test
593     @Alerts("")
594     public void getInnerTextWhiteSpaceTextAreaNormal() throws Exception {
595         getInnerTextWhiteSpaceTextArea("normal");
596     }
597 
598     /**
599      * Verifies getInnerText().
600      * @throws Exception if the test fails
601      */
602     @Test
603     @Alerts("")
604     public void getInnerTextWhiteSpaceTextAreaNowrap() throws Exception {
605         getInnerTextWhiteSpaceTextArea("nowrap");
606     }
607 
608     /**
609      * Verifies getInnerText().
610      * @throws Exception if the test fails
611      */
612     @Test
613     @Alerts("")
614     public void getInnerTextWhiteSpaceTextAreaPre() throws Exception {
615         getInnerTextWhiteSpaceTextArea("pre");
616     }
617 
618     /**
619      * Verifies getInnerText().
620      * @throws Exception if the test fails
621      */
622     @Test
623     @Alerts("")
624     public void getInnerTextWhiteSpaceTextAreaPreWrap() throws Exception {
625         getInnerTextWhiteSpaceTextArea("pre-wrap");
626     }
627 
628     /**
629      * Verifies getInnerText().
630      * @throws Exception if the test fails
631      */
632     @Test
633     @Alerts("")
634     public void getInnerTextWhiteSpaceTextAreaPreLine() throws Exception {
635         getInnerTextWhiteSpaceTextArea("pre-line");
636     }
637 
638     private void getInnerTextWhiteSpaceTextArea(final String whiteSpace) throws Exception {
639         final String htmlContent = DOCTYPE_HTML
640             + "<html>\n"
641             + "<head></head>\n"
642             + "<body>\n"
643             + "  <textarea id='tester' " + (whiteSpace == null ? "" : ("style='white-space: " + whiteSpace + "'")) + ">"
644                     + "  A B  C\t \t  D \r\nEF\nG \n H  <br> I  </textarea>\n"
645             + "</body></html>";
646 
647         final WebDriver driver = loadPage2(htmlContent);
648         final String text = (String) ((JavascriptExecutor) driver)
649                 .executeScript("return document.getElementById('tester').innerText");
650         assertEquals(getExpectedAlerts()[0], text);
651     }
652 
653     /**
654      * Verifies getInnerText().
655      * @throws Exception if the test fails
656      */
657     @Test
658     @Alerts("  A B  C\t \t  D \nEF\nG \n H  <br> I  ")
659     public void getInnerTextWhiteSpaceTitle() throws Exception {
660         getInnerTextWhiteSpaceTitle(null);
661     }
662 
663     /**
664      * Verifies getInnerText().
665      * @throws Exception if the test fails
666      */
667     @Test
668     @Alerts("  A B  C\t \t  D \nEF\nG \n H  <br> I  ")
669     public void getInnerTextWhiteSpaceTitleNormal() throws Exception {
670         getInnerTextWhiteSpaceTitle("normal");
671     }
672 
673     /**
674      * Verifies getInnerText().
675      * @throws Exception if the test fails
676      */
677     @Test
678     @Alerts("  A B  C\t \t  D \nEF\nG \n H  <br> I  ")
679     public void getInnerTextWhiteSpaceTitleNowrap() throws Exception {
680         getInnerTextWhiteSpaceTitle("nowrap");
681     }
682 
683     /**
684      * Verifies getInnerText().
685      * @throws Exception if the test fails
686      */
687     @Test
688     @Alerts("  A B  C\t \t  D \nEF\nG \n H  <br> I  ")
689     public void getInnerTextWhiteSpaceTitlePre() throws Exception {
690         getInnerTextWhiteSpaceTitle("pre");
691     }
692 
693     /**
694      * Verifies getInnerText().
695      * @throws Exception if the test fails
696      */
697     @Test
698     @Alerts("  A B  C\t \t  D \nEF\nG \n H  <br> I  ")
699     public void getInnerTextWhiteSpaceTitlePreWrap() throws Exception {
700         getInnerTextWhiteSpaceTitle("pre-wrap");
701     }
702 
703     /**
704      * Verifies getInnerText().
705      * @throws Exception if the test fails
706      */
707     @Test
708     @Alerts("  A B  C\t \t  D \nEF\nG \n H  <br> I  ")
709     public void getInnerTextWhiteSpaceTitlePreLine() throws Exception {
710         getInnerTextWhiteSpaceTitle("pre-line");
711     }
712 
713     private void getInnerTextWhiteSpaceTitle(final String whiteSpace) throws Exception {
714         final String htmlContent = DOCTYPE_HTML
715             + "<html>\n"
716             + "<head>\n"
717             + "<title id='tester' " + (whiteSpace == null ? "" : ("style='white-space: " + whiteSpace + "'")) + ">"
718             + "  A B  C\t \t  D \r\nEF\nG \n H  <br> I  </title>\n"
719             + "</head>\n"
720             + "<body>\n"
721             + "</body></html>";
722 
723         final WebDriver driver = loadPage2(htmlContent);
724         final String text = (String) ((JavascriptExecutor) driver)
725                 .executeScript("return document.getElementById('tester').innerText");
726         assertEquals(getExpectedAlerts()[0], text);
727     }
728 
729     /**
730      * Verifies getInnerText().
731      * @throws Exception if the test fails
732      */
733     @Test
734     @Alerts(DEFAULT = "A B C D EF G H I\nSecond",
735             FF = "",
736             FF_ESR = "")
737     @HtmlUnitNYI(CHROME = "A B C D EF G H I Second",
738             EDGE = "A B C D EF G H I Second",
739             FF = "A B C D EF G H I Second",
740             FF_ESR = "A B C D EF G H I Second")
741     public void getInnerTextWhiteSpaceSelect() throws Exception {
742         getInnerTextWhiteSpaceSelect(null);
743     }
744 
745     /**
746      * Verifies getInnerText().
747      * @throws Exception if the test fails
748      */
749     @Test
750     @Alerts(DEFAULT = "A B C D EF G H I\nSecond",
751             FF = "",
752             FF_ESR = "")
753     @HtmlUnitNYI(CHROME = "A B C D EF G H I Second",
754             EDGE = "A B C D EF G H I Second",
755             FF = "A B C D EF G H I Second",
756             FF_ESR = "A B C D EF G H I Second")
757     public void getInnerTextWhiteSpaceSelectNormal() throws Exception {
758         getInnerTextWhiteSpaceSelect("normal");
759     }
760 
761     /**
762      * Verifies getInnerText().
763      * @throws Exception if the test fails
764      */
765     @Test
766     @Alerts(DEFAULT = "A B C D EF G H I\nSecond",
767             FF = "",
768             FF_ESR = "")
769     @HtmlUnitNYI(CHROME = "A B C D EF G H I Second",
770             EDGE = "A B C D EF G H I Second",
771             FF = "A B C D EF G H I Second",
772             FF_ESR = "A B C D EF G H I Second")
773     public void getInnerTextWhiteSpaceSelectNowrap() throws Exception {
774         getInnerTextWhiteSpaceSelect("nowrap");
775     }
776 
777     /**
778      * Verifies getInnerText().
779      * @throws Exception if the test fails
780      */
781     @Test
782     @Alerts(DEFAULT = "A B C D EF G H I\nSecond",
783             FF = "",
784             FF_ESR = "")
785     @HtmlUnitNYI(CHROME = "        A B  C\t \t  D \nEF\nG \n H   I  \n      Second\n    ",
786             EDGE = "        A B  C\t \t  D \nEF\nG \n H   I  \n      Second\n    ",
787             FF = "        A B  C\t \t  D \nEF\nG \n H   I  \n      Second\n    ",
788             FF_ESR = "        A B  C\t \t  D \nEF\nG \n H   I  \n      Second\n    ")
789     public void getInnerTextWhiteSpaceSelectPre() throws Exception {
790         getInnerTextWhiteSpaceSelect("pre");
791     }
792 
793     /**
794      * Verifies getInnerText().
795      * @throws Exception if the test fails
796      */
797     @Test
798     @Alerts(DEFAULT = "A B C D EF G H I\nSecond",
799             FF = "",
800             FF_ESR = "")
801     @HtmlUnitNYI(CHROME = "        A B  C\t \t  D \nEF\nG \n H   I  \n      Second\n    ",
802             EDGE = "        A B  C\t \t  D \nEF\nG \n H   I  \n      Second\n    ",
803             FF = "        A B  C\t \t  D \nEF\nG \n H   I  \n      Second\n    ",
804             FF_ESR = "        A B  C\t \t  D \nEF\nG \n H   I  \n      Second\n    ")
805     public void getInnerTextWhiteSpaceSelectPreWrap() throws Exception {
806         getInnerTextWhiteSpaceSelect("pre-wrap");
807     }
808 
809     /**
810      * Verifies getInnerText().
811      * @throws Exception if the test fails
812      */
813     @Test
814     @Alerts(DEFAULT = "A B C D EF G H I\nSecond",
815             FF = "",
816             FF_ESR = "")
817     @HtmlUnitNYI(CHROME = "A B C D\nEF\nG\nH I\nSecond\n",
818             EDGE = "A B C D\nEF\nG\nH I\nSecond\n",
819             FF = "A B C D\nEF\nG\nH I\nSecond\n",
820             FF_ESR = "A B C D\nEF\nG\nH I\nSecond\n")
821     public void getInnerTextWhiteSpaceSelectPreLine() throws Exception {
822         getInnerTextWhiteSpaceSelect("pre-line");
823     }
824 
825     private void getInnerTextWhiteSpaceSelect(final String whiteSpace) throws Exception {
826         final String htmlContent = DOCTYPE_HTML
827             + "<html>\n"
828             + "<head></head>\n"
829             + "<body>\n"
830             + "  <form>\n"
831             + "    <select id='tester' "
832                     + (whiteSpace == null ? "" : ("style='white-space: " + whiteSpace + "'")) + ">\n"
833             + "      <option>  A B  C\t \t  D \r\nEF\nG \n H  <br> I  </option>\n"
834             + "      <option>Second</option>\n"
835             + "    </select>\n"
836             + "</body></html>";
837 
838         final WebDriver driver = loadPage2(htmlContent);
839         final String text = (String) ((JavascriptExecutor) driver)
840                 .executeScript("return document.getElementById('tester').innerText");
841         assertEquals(getExpectedAlerts()[0], text);
842     }
843 
844     /**
845      * Verifies getInnerText().
846      * @throws Exception if the test fails
847      */
848     @Test
849     @Alerts("")
850     public void getInnerTextWhiteSpaceInputSubmit() throws Exception {
851         getInnerTextWhiteSpaceInputSubmit(null);
852     }
853 
854     /**
855      * Verifies getInnerText().
856      * @throws Exception if the test fails
857      */
858     @Test
859     @Alerts("")
860     public void getInnerTextWhiteSpaceInputSubmitNormal() throws Exception {
861         getInnerTextWhiteSpaceInputSubmit("normal");
862     }
863 
864     /**
865      * Verifies getInnerText().
866      * @throws Exception if the test fails
867      */
868     @Test
869     @Alerts("")
870     public void getInnerTextWhiteSpaceInputSubmitNowrap() throws Exception {
871         getInnerTextWhiteSpaceInputSubmit("nowrap");
872     }
873 
874     /**
875      * Verifies getInnerText().
876      * @throws Exception if the test fails
877      */
878     @Test
879     @Alerts("")
880     public void getInnerTextWhiteSpaceInputSubmitPre() throws Exception {
881         getInnerTextWhiteSpaceInputSubmit("pre");
882     }
883 
884     /**
885      * Verifies getInnerText().
886      * @throws Exception if the test fails
887      */
888     @Test
889     @Alerts("")
890     public void getInnerTextWhiteSpaceInputSubmitPreWrap() throws Exception {
891         getInnerTextWhiteSpaceInputSubmit("pre-wrap");
892     }
893 
894     /**
895      * Verifies getInnerText().
896      * @throws Exception if the test fails
897      */
898     @Test
899     @Alerts("")
900     public void getInnerTextWhiteSpaceInputSubmitPreLine() throws Exception {
901         getInnerTextWhiteSpaceInputSubmit("pre-line");
902     }
903 
904     private void getInnerTextWhiteSpaceInputSubmit(final String whiteSpace) throws Exception {
905         final String htmlContent = DOCTYPE_HTML
906             + "<html>\n"
907             + "<head></head>\n"
908             + "<body>\n"
909             + "<form id='form1'>\n"
910             + "  <input type='submit' name='tester' id='tester' "
911                         + (whiteSpace == null ? "" : ("style='white-space: " + whiteSpace + "'"))
912                         + " value='  A B  C\t \t  D \r\nEF\nG \n H  <br> I  '>\n"
913             + "</form>\n"
914             + "</body></html>";
915 
916         final WebDriver driver = loadPage2(htmlContent);
917         final String text = (String) ((JavascriptExecutor) driver)
918                 .executeScript("return document.getElementById('tester').innerText");
919         assertEquals(getExpectedAlerts()[0], text);
920     }
921 
922     /**
923      * Verifies getInnerText().
924      * @throws Exception if the test fails
925      */
926     @Test
927     @Alerts("")
928     public void getInnerTextInputSubmitNoValue() throws Exception {
929         final String htmlContent = DOCTYPE_HTML
930             + "<html>\n"
931             + "<head></head>\n"
932             + "<body>\n"
933             + "<form id='form1'>\n"
934             + "  <input type='submit' name='tester' id='tester' >\n"
935             + "</form>\n"
936             + "</body></html>";
937 
938         final WebDriver driver = loadPage2(htmlContent);
939         final String text = (String) ((JavascriptExecutor) driver)
940                 .executeScript("return document.getElementById('tester').innerText");
941         assertEquals(getExpectedAlerts()[0], text);
942     }
943 
944     /**
945      * Verifies getInnerText().
946      * @throws Exception if the test fails
947      */
948     @Test
949     @Alerts("")
950     public void getInnerTextInputResetNoValue() throws Exception {
951         final String htmlContent = DOCTYPE_HTML
952             + "<html>\n"
953             + "<head></head>\n"
954             + "<body>\n"
955             + "<form id='form1'>\n"
956             + "  <input type='reset' name='tester' id='tester' >\n"
957             + "</form>\n"
958             + "</body></html>";
959 
960         final WebDriver driver = loadPage2(htmlContent);
961         final String text = (String) ((JavascriptExecutor) driver)
962                 .executeScript("return document.getElementById('tester').innerText");
963         assertEquals(getExpectedAlerts()[0], text);
964     }
965 
966     /**
967      * Verifies getInnerText().
968      * @throws Exception if the test fails
969      */
970     @Test
971     @Alerts("")
972     public void getInnerTextInputResetBlankValue() throws Exception {
973         final String htmlContent = DOCTYPE_HTML
974             + "<html>\n"
975             + "<head></head>\n"
976             + "<body>\n"
977             + "<form id='form1'>\n"
978             + "  <input type='reset' name='tester' id='tester' value='  \t'>\n"
979             + "</form>\n"
980             + "</body></html>";
981 
982         final WebDriver driver = loadPage2(htmlContent);
983         final String text = (String) ((JavascriptExecutor) driver)
984                 .executeScript("return document.getElementById('tester').innerText");
985         assertEquals(getExpectedAlerts()[0], text);
986     }
987 
988     /**
989      * Verifies getInnerText().
990      * @throws Exception if the test fails
991      */
992     @Test
993     @Alerts("")
994     public void getInnerTextInputSubmitBlankValue() throws Exception {
995         final String htmlContent = DOCTYPE_HTML
996             + "<html>\n"
997             + "<head></head>\n"
998             + "<body>\n"
999             + "<form id='form1'>\n"
1000             + "  <input type='submit' name='tester' id='tester' value='  \t'>\n"
1001             + "</form>\n"
1002             + "</body></html>";
1003 
1004         final WebDriver driver = loadPage2(htmlContent);
1005         final String text = (String) ((JavascriptExecutor) driver)
1006                 .executeScript("return document.getElementById('tester').innerText");
1007         assertEquals(getExpectedAlerts()[0], text);
1008     }
1009 
1010     /**
1011      * Verifies getInnerText().
1012      * @throws Exception if the test fails
1013      */
1014     @Test
1015     @Alerts("")
1016     public void getInnerTextWhiteSpaceInputReset() throws Exception {
1017         getInnerTextWhiteSpaceInputReset(null);
1018     }
1019 
1020     /**
1021      * Verifies getInnerText().
1022      * @throws Exception if the test fails
1023      */
1024     @Test
1025     @Alerts("")
1026     public void getInnerTextWhiteSpaceInputResetNormal() throws Exception {
1027         getInnerTextWhiteSpaceInputReset("normal");
1028     }
1029 
1030     /**
1031      * Verifies getInnerText().
1032      * @throws Exception if the test fails
1033      */
1034     @Test
1035     @Alerts("")
1036     public void getInnerTextWhiteSpaceInputResetNowrap() throws Exception {
1037         getInnerTextWhiteSpaceInputReset("nowrap");
1038     }
1039 
1040     /**
1041      * Verifies getInnerText().
1042      * @throws Exception if the test fails
1043      */
1044     @Test
1045     @Alerts("")
1046     public void getInnerTextWhiteSpaceInputResetPre() throws Exception {
1047         getInnerTextWhiteSpaceInputReset("pre");
1048     }
1049 
1050     /**
1051      * Verifies getInnerText().
1052      * @throws Exception if the test fails
1053      */
1054     @Test
1055     @Alerts("")
1056     public void getInnerTextWhiteSpaceInputResetPreWrap() throws Exception {
1057         getInnerTextWhiteSpaceInputReset("pre-wrap");
1058     }
1059 
1060     /**
1061      * Verifies getInnerText().
1062      * @throws Exception if the test fails
1063      */
1064     @Test
1065     @Alerts("")
1066     public void getInnerTextWhiteSpaceInputResetPreLine() throws Exception {
1067         getInnerTextWhiteSpaceInputReset("pre-line");
1068     }
1069 
1070     private void getInnerTextWhiteSpaceInputReset(final String whiteSpace) throws Exception {
1071         final String htmlContent = DOCTYPE_HTML
1072             + "<html>\n"
1073             + "<head></head>\n"
1074             + "<body>\n"
1075             + "<form id='form1'>\n"
1076             + "  <input type='reset' name='tester' id='tester' "
1077                         + (whiteSpace == null ? "" : ("style='white-space: " + whiteSpace + "'"))
1078                         + " value='  A B  C\t \t  D \r\nEF\nG \n H  <br> I  '>\n"
1079             + "</form>\n"
1080             + "</body></html>";
1081 
1082         final WebDriver driver = loadPage2(htmlContent);
1083         final String text = (String) ((JavascriptExecutor) driver)
1084                 .executeScript("return document.getElementById('tester').innerText");
1085         assertEquals(getExpectedAlerts()[0], text);
1086     }
1087 
1088     /**
1089      * Verifies getInnerText().
1090      * @throws Exception if the test fails
1091      */
1092     @Test
1093     @Alerts("")
1094     public void getInnerTextWhiteSpaceInputCheckbox() throws Exception {
1095         getInnerTextWhiteSpaceInputCheckbox(null);
1096     }
1097 
1098     /**
1099      * Verifies getInnerText().
1100      * @throws Exception if the test fails
1101      */
1102     @Test
1103     @Alerts("")
1104     public void getInnerTextWhiteSpaceInputCheckboxNormal() throws Exception {
1105         getInnerTextWhiteSpaceInputCheckbox("normal");
1106     }
1107 
1108     /**
1109      * Verifies getInnerText().
1110      * @throws Exception if the test fails
1111      */
1112     @Test
1113     @Alerts("")
1114     public void getInnerTextWhiteSpaceInputCheckboxNowrap() throws Exception {
1115         getInnerTextWhiteSpaceInputCheckbox("nowrap");
1116     }
1117 
1118     /**
1119      * Verifies getInnerText().
1120      * @throws Exception if the test fails
1121      */
1122     @Test
1123     @Alerts("")
1124     public void getInnerTextWhiteSpaceInputCheckboxPre() throws Exception {
1125         getInnerTextWhiteSpaceInputCheckbox("pre");
1126     }
1127 
1128     /**
1129      * Verifies getInnerText().
1130      * @throws Exception if the test fails
1131      */
1132     @Test
1133     @Alerts("")
1134     public void getInnerTextWhiteSpaceInputCheckboxPreWrap() throws Exception {
1135         getInnerTextWhiteSpaceInputCheckbox("pre-wrap");
1136     }
1137 
1138     /**
1139      * Verifies getInnerText().
1140      * @throws Exception if the test fails
1141      */
1142     @Test
1143     @Alerts("")
1144     public void getInnerTextWhiteSpaceInputCheckboxPreLine() throws Exception {
1145         getInnerTextWhiteSpaceInputCheckbox("pre-line");
1146     }
1147 
1148     private void getInnerTextWhiteSpaceInputCheckbox(final String whiteSpace) throws Exception {
1149         final String htmlContent = DOCTYPE_HTML
1150             + "<html>\n"
1151             + "<head></head>\n"
1152             + "<body>\n"
1153             + "<form id='form1'>\n"
1154             + "  <input type='checkbox' name='tester' id='tester' "
1155                         + (whiteSpace == null ? "" : ("style='white-space: " + whiteSpace + "'"))
1156                         + " value='  A B  C\t \t  D \r\nEF\nG \n H  <br> I  '>\n"
1157             + "</form>\n"
1158             + "</body></html>";
1159 
1160         final WebDriver driver = loadPage2(htmlContent);
1161         final String text = (String) ((JavascriptExecutor) driver)
1162                 .executeScript("return document.getElementById('tester').innerText");
1163         assertEquals(getExpectedAlerts()[0], text);
1164     }
1165 
1166     /**
1167      * Verifies getInnerText().
1168      * @throws Exception if the test fails
1169      */
1170     @Test
1171     @Alerts("")
1172     public void getInnerTextWhiteSpaceInputRadio() throws Exception {
1173         getInnerTextWhiteSpaceInputRadio(null);
1174     }
1175 
1176     /**
1177      * Verifies getInnerText().
1178      * @throws Exception if the test fails
1179      */
1180     @Test
1181     @Alerts("")
1182     public void getInnerTextWhiteSpaceInputRadioNormal() throws Exception {
1183         getInnerTextWhiteSpaceInputRadio("normal");
1184     }
1185 
1186     /**
1187      * Verifies getInnerText().
1188      * @throws Exception if the test fails
1189      */
1190     @Test
1191     @Alerts("")
1192     public void getInnerTextWhiteSpaceInputRadioNowrap() throws Exception {
1193         getInnerTextWhiteSpaceInputRadio("nowrap");
1194     }
1195 
1196     /**
1197      * Verifies getInnerText().
1198      * @throws Exception if the test fails
1199      */
1200     @Test
1201     @Alerts("")
1202     public void getInnerTextWhiteSpaceInputRadioPre() throws Exception {
1203         getInnerTextWhiteSpaceInputRadio("pre");
1204     }
1205 
1206     /**
1207      * Verifies getInnerText().
1208      * @throws Exception if the test fails
1209      */
1210     @Test
1211     @Alerts("")
1212     public void getInnerTextWhiteSpaceInputRadioPreWrap() throws Exception {
1213         getInnerTextWhiteSpaceInputRadio("pre-wrap");
1214     }
1215 
1216     /**
1217      * Verifies getInnerText().
1218      * @throws Exception if the test fails
1219      */
1220     @Test
1221     @Alerts("")
1222     public void getInnerTextWhiteSpaceInputRadioPreLine() throws Exception {
1223         getInnerTextWhiteSpaceInputRadio("pre-line");
1224     }
1225 
1226     private void getInnerTextWhiteSpaceInputRadio(final String whiteSpace) throws Exception {
1227         final String htmlContent = DOCTYPE_HTML
1228             + "<html>\n"
1229             + "<head></head>\n"
1230             + "<body>\n"
1231             + "<form id='form1'>\n"
1232             + "  <input type='radio' name='tester' id='tester' "
1233                         + (whiteSpace == null ? "" : ("style='white-space: " + whiteSpace + "'"))
1234                         + " value='  A B  C\t \t  D \r\nEF\nG \n H  <br> I  '>\n"
1235             + "</form>\n"
1236             + "</body></html>";
1237 
1238         final WebDriver driver = loadPage2(htmlContent);
1239         final String text = (String) ((JavascriptExecutor) driver)
1240                 .executeScript("return document.getElementById('tester').innerText");
1241         assertEquals(getExpectedAlerts()[0], text);
1242     }
1243 
1244     /**
1245      * Verifies getInnerText().
1246      * @throws Exception if the test fails
1247      */
1248     @Test
1249     @Alerts("first item\nA B C D EF G H\nI\nthird item\n4. item\nsome text\nlast item")
1250     public void getInnerTextWhiteSpaceOrderedList() throws Exception {
1251         getInnerTextWhiteSpaceOrderedList(null);
1252     }
1253 
1254     /**
1255      * Verifies getInnerText().
1256      * @throws Exception if the test fails
1257      */
1258     @Test
1259     @Alerts("first item\nA B C D EF G H\nI\nthird item\n4. item\nsome text\nlast item")
1260     public void getInnerTextWhiteSpaceOrderedListNormal() throws Exception {
1261         getInnerTextWhiteSpaceOrderedList("normal");
1262     }
1263 
1264     /**
1265      * Verifies getInnerText().
1266      * @throws Exception if the test fails
1267      */
1268     @Test
1269     @Alerts("first item\nA B C D EF G H\nI\nthird item\n4. item\nsome text\nlast item")
1270     public void getInnerTextWhiteSpaceOrderedListNowrap() throws Exception {
1271         getInnerTextWhiteSpaceOrderedList("nowrap");
1272     }
1273 
1274     /**
1275      * Verifies getInnerText().
1276      * @throws Exception if the test fails
1277      */
1278     @Test
1279     @Alerts("\n    \nfirst item\n\n    \n  A B  C\t \t  D \nEF\nG \n H  \n I  \n"
1280                 + "\n    \nthird item\n4. item\n\n    some text \n    \nlast item\n\n  ")
1281     @HtmlUnitNYI(CHROME = "    \nfirst item\n\n    \n  A B  C\t \t  D \nEF\nG \n H  \n I  \n"
1282                 + "\n    \nthird item\n4. item\n\n    some text \n    \nlast item\n\n  ",
1283             EDGE = "    \nfirst item\n\n    \n  A B  C\t \t  D \nEF\nG \n H  \n I  \n"
1284                 + "\n    \nthird item\n4. item\n\n    some text \n    \nlast item\n\n  ",
1285             FF = "    \nfirst item\n\n    \n  A B  C\t \t  D \nEF\nG \n H  \n I  \n"
1286                 + "\n    \nthird item\n4. item\n\n    some text \n    \nlast item\n\n  ",
1287             FF_ESR = "    \nfirst item\n\n    \n  A B  C\t \t  D \nEF\nG \n H  \n I  \n"
1288                 + "\n    \nthird item\n4. item\n\n    some text \n    \nlast item\n\n  ")
1289     public void getInnerTextWhiteSpaceOrderedListPre() throws Exception {
1290         getInnerTextWhiteSpaceOrderedList("pre");
1291     }
1292 
1293     /**
1294      * Verifies getInnerText().
1295      * @throws Exception if the test fails
1296      */
1297     @Test
1298     @Alerts("\n    \nfirst item\n\n    \n  A B  C\t \t  D \nEF\nG \n H  \n I  \n"
1299                 + "\n    \nthird item\n4. item\n\n    some text \n    \nlast item\n\n  ")
1300     @HtmlUnitNYI(CHROME = "    \nfirst item\n\n    \n  A B  C\t \t  D \nEF\nG \n H  \n I  \n"
1301                 + "\n    \nthird item\n4. item\n\n    some text \n    \nlast item\n\n  ",
1302             EDGE = "    \nfirst item\n\n    \n  A B  C\t \t  D \nEF\nG \n H  \n I  \n"
1303                 + "\n    \nthird item\n4. item\n\n    some text \n    \nlast item\n\n  ",
1304             FF = "    \nfirst item\n\n    \n  A B  C\t \t  D \nEF\nG \n H  \n I  \n"
1305                 + "\n    \nthird item\n4. item\n\n    some text \n    \nlast item\n\n  ",
1306             FF_ESR = "    \nfirst item\n\n    \n  A B  C\t \t  D \nEF\nG \n H  \n I  \n"
1307                 + "\n    \nthird item\n4. item\n\n    some text \n    \nlast item\n\n  ")
1308     public void getInnerTextWhiteSpaceOrderedListPreWrap() throws Exception {
1309         getInnerTextWhiteSpaceOrderedList("pre-wrap");
1310     }
1311 
1312     /**
1313      * Verifies getInnerText().
1314      * @throws Exception if the test fails
1315      */
1316     @Test
1317     @Alerts(DEFAULT = "\n\nfirst item\n\n\nA B C D\nEF\nG\nH\nI"
1318                 + "\n\n\nthird item\n4. item\n\nsome text\n\nlast item\n\n",
1319             FF_ESR = "first item\nA B C D\nEFGH\nI\nthird item\n4. item\nsome text\nlast item")
1320     @HtmlUnitNYI(CHROME = "first item\n\n\n A B C D\nEF\nG\nH\n I"
1321                 + "\n\n\nthird item\n4. item\n\nsome text\n\nlast item\n\n",
1322             EDGE = "first item\n\n\n A B C D\nEF\nG\nH\n I"
1323                 + "\n\n\nthird item\n4. item\n\nsome text\n\nlast item\n\n",
1324             FF = "first item\n\n\n A B C D\nEF\nG\nH\n I"
1325                 + "\n\n\nthird item\n4. item\n\nsome text\n\nlast item\n\n",
1326             FF_ESR = "first item\n\n\n A B C D\nEF\nG\nH\n I"
1327                 + "\n\n\nthird item\n4. item\n\nsome text\n\nlast item\n\n")
1328     public void getInnerTextWhiteSpaceOrderedListPreLine() throws Exception {
1329         getInnerTextWhiteSpaceOrderedList("pre-line");
1330     }
1331 
1332     private void getInnerTextWhiteSpaceOrderedList(final String whiteSpace) throws Exception {
1333         final String htmlContent = DOCTYPE_HTML
1334             + "<html>\n"
1335             + "<head></head>\n"
1336             + "<body>\n"
1337             + "  <ol id='tester' " + (whiteSpace == null ? "" : ("style='white-space: " + whiteSpace + "'")) + ">\n"
1338             + "    <li>first item</li>\n"
1339             + "    <li>  A B  C\t \t  D \r\nEF\nG \n H  <br> I  </li>\n"
1340             + "    <li>third item</li><li>4. item</li>\n"
1341             + "    some text \n"
1342             + "    <li>last item</li>\n"
1343             + "  </ol>\n"
1344             + "</body></html>";
1345 
1346         final WebDriver driver = loadPage2(htmlContent);
1347         final String text = (String) ((JavascriptExecutor) driver)
1348                 .executeScript("return document.getElementById('tester').innerText");
1349         assertEquals(getExpectedAlerts()[0], text);
1350     }
1351 
1352     /**
1353      * Verifies getInnerText().
1354      * @throws Exception if the test fails
1355      */
1356     @Test
1357     @Alerts("first item\nA B C D EF G H\nI\nthird item\n4. item\nsome text\nlast item")
1358     public void getInnerTextWhiteSpaceUnorderedList() throws Exception {
1359         getInnerTextWhiteSpaceUnorderedList(null);
1360     }
1361 
1362     /**
1363      * Verifies getInnerText().
1364      * @throws Exception if the test fails
1365      */
1366     @Test
1367     @Alerts("first item\nA B C D EF G H\nI\nthird item\n4. item\nsome text\nlast item")
1368     public void getInnerTextWhiteSpaceUnorderedListNormal() throws Exception {
1369         getInnerTextWhiteSpaceUnorderedList("normal");
1370     }
1371 
1372     /**
1373      * Verifies getInnerText().
1374      * @throws Exception if the test fails
1375      */
1376     @Test
1377     @Alerts("first item\nA B C D EF G H\nI\nthird item\n4. item\nsome text\nlast item")
1378     public void getInnerTextWhiteSpaceUnorderedListNowrap() throws Exception {
1379         getInnerTextWhiteSpaceUnorderedList("nowrap");
1380     }
1381 
1382     /**
1383      * Verifies getInnerText().
1384      * @throws Exception if the test fails
1385      */
1386     @Test
1387     @Alerts("\n    \nfirst item\n\n    \n  A B  C\t \t  D \nEF\nG \n H  \n I  \n"
1388                 + "\n    \nthird item\n4. item\n\n    some text \n    \nlast item\n\n  ")
1389     @HtmlUnitNYI(CHROME = "    \nfirst item\n\n    \n  A B  C\t \t  D \nEF\nG \n H  \n I  \n"
1390                 + "\n    \nthird item\n4. item\n\n    some text \n    \nlast item\n\n  ",
1391             EDGE = "    \nfirst item\n\n    \n  A B  C\t \t  D \nEF\nG \n H  \n I  \n"
1392                 + "\n    \nthird item\n4. item\n\n    some text \n    \nlast item\n\n  ",
1393             FF = "    \nfirst item\n\n    \n  A B  C\t \t  D \nEF\nG \n H  \n I  \n"
1394                 + "\n    \nthird item\n4. item\n\n    some text \n    \nlast item\n\n  ",
1395             FF_ESR = "    \nfirst item\n\n    \n  A B  C\t \t  D \nEF\nG \n H  \n I  \n"
1396                 + "\n    \nthird item\n4. item\n\n    some text \n    \nlast item\n\n  ")
1397     public void getInnerTextWhiteSpaceUnorderedListPre() throws Exception {
1398         getInnerTextWhiteSpaceUnorderedList("pre");
1399     }
1400 
1401     /**
1402      * Verifies getInnerText().
1403      * @throws Exception if the test fails
1404      */
1405     @Test
1406     @Alerts("\n    \nfirst item\n\n    \n  A B  C\t \t  D \nEF\nG \n H  \n I  \n"
1407                 + "\n    \nthird item\n4. item\n\n    some text \n    \nlast item\n\n  ")
1408     @HtmlUnitNYI(CHROME = "    \nfirst item\n\n    \n  A B  C\t \t  D \nEF\nG \n H  \n I  \n"
1409                 + "\n    \nthird item\n4. item\n\n    some text \n    \nlast item\n\n  ",
1410             EDGE = "    \nfirst item\n\n    \n  A B  C\t \t  D \nEF\nG \n H  \n I  \n"
1411                 + "\n    \nthird item\n4. item\n\n    some text \n    \nlast item\n\n  ",
1412             FF = "    \nfirst item\n\n    \n  A B  C\t \t  D \nEF\nG \n H  \n I  \n"
1413                 + "\n    \nthird item\n4. item\n\n    some text \n    \nlast item\n\n  ",
1414             FF_ESR = "    \nfirst item\n\n    \n  A B  C\t \t  D \nEF\nG \n H  \n I  \n"
1415                 + "\n    \nthird item\n4. item\n\n    some text \n    \nlast item\n\n  ")
1416     public void getInnerTextWhiteSpaceUnorderedListPreWrap() throws Exception {
1417         getInnerTextWhiteSpaceUnorderedList("pre-wrap");
1418     }
1419 
1420     /**
1421      * Verifies getInnerText().
1422      * @throws Exception if the test fails
1423      */
1424     @Test
1425     @Alerts(DEFAULT = "\n\nfirst item\n\n\nA B C D\nEF\nG\nH\nI\n"
1426                 + "\n\nthird item\n4. item\n\nsome text\n\nlast item\n\n",
1427             FF_ESR = "first item\nA B C D\nEFGH\nI\nthird item\n4. item\nsome text\nlast item")
1428     @HtmlUnitNYI(CHROME = "first item\n\n\n A B C D\nEF\nG\nH\n I"
1429                 + "\n\n\nthird item\n4. item\n\nsome text\n\nlast item\n\n",
1430             EDGE = "first item\n\n\n A B C D\nEF\nG\nH\n I"
1431                 + "\n\n\nthird item\n4. item\n\nsome text\n\nlast item\n\n",
1432             FF = "first item\n\n\n A B C D\nEF\nG\nH\n I"
1433                 + "\n\n\nthird item\n4. item\n\nsome text\n\nlast item\n\n",
1434             FF_ESR = "first item\n\n\n A B C D\nEF\nG\nH\n I"
1435                 + "\n\n\nthird item\n4. item\n\nsome text\n\nlast item\n\n")
1436     public void getInnerTextWhiteSpaceUnorderedListPreLine() throws Exception {
1437         getInnerTextWhiteSpaceUnorderedList("pre-line");
1438     }
1439 
1440     private void getInnerTextWhiteSpaceUnorderedList(final String whiteSpace) throws Exception {
1441         final String htmlContent = DOCTYPE_HTML
1442             + "<html>\n"
1443             + "<head></head>\n"
1444             + "<body>\n"
1445             + "  <ul id='tester' " + (whiteSpace == null ? "" : ("style='white-space: " + whiteSpace + "'")) + ">\n"
1446             + "    <li>first item</li>\n"
1447             + "    <li>  A B  C\t \t  D \r\nEF\nG \n H  <br> I  </li>\n"
1448             + "    <li>third item</li><li>4. item</li>\n"
1449             + "    some text \n"
1450             + "    <li>last item</li>\n"
1451             + "  </ul>\n"
1452             + "</body></html>";
1453 
1454         final WebDriver driver = loadPage2(htmlContent);
1455         final String text = (String) ((JavascriptExecutor) driver)
1456                 .executeScript("return document.getElementById('tester').innerText");
1457         assertEquals(getExpectedAlerts()[0], text);
1458     }
1459 
1460     /**
1461      * Verifies getInnerText().
1462      * @throws Exception if the test fails
1463      */
1464     @Test
1465     @Alerts("The text to be tested")
1466     public void getInnerTextLabel() throws Exception {
1467         getInnerTextFormated("<label id='tester'>The text to be <span>tested</span></label>");
1468     }
1469 
1470     /**
1471      * Verifies getInnerText().
1472      * @throws Exception if the test fails
1473      */
1474     @Test
1475     @Alerts("The text to be tested")
1476     public void getInnerTextLabelNormal() throws Exception {
1477         getInnerTextFormated("<label id='tester' style='white-space: normal'>"
1478                 + "The text to be <span>tested</span></label>");
1479     }
1480 
1481     /**
1482      * Verifies getInnerText().
1483      * @throws Exception if the test fails
1484      */
1485     @Test
1486     @Alerts("The text to be tested")
1487     public void getInnerTextLabelNowrap() throws Exception {
1488         getInnerTextFormated("<label id='tester' style='white-space: nowrap'>"
1489                 + "The text to be <span>tested</span></label>");
1490     }
1491 
1492     /**
1493      * Verifies getInnerText().
1494      * @throws Exception if the test fails
1495      */
1496     @Test
1497     @Alerts("The text to be tested")
1498     public void getInnerTextLabelPre() throws Exception {
1499         getInnerTextFormated("<label id='tester' style='white-space: pre'>"
1500                 + "The text to be <span>tested</span></label>");
1501     }
1502 
1503     /**
1504      * Verifies getInnerText().
1505      * @throws Exception if the test fails
1506      */
1507     @Test
1508     @Alerts("The text to be tested")
1509     public void getInnerTextLabelPreWrap() throws Exception {
1510         getInnerTextFormated("<label id='tester' style='white-space: pre-wrap'>"
1511                 + "The text to be <span>tested</span></label>");
1512     }
1513 
1514     /**
1515      * Verifies getInnerText().
1516      * @throws Exception if the test fails
1517      */
1518     @Test
1519     @Alerts("The text to be tested")
1520     public void getInnerTextLabelPreLine() throws Exception {
1521         getInnerTextFormated("<label id='tester' style='white-space: pre-line'>"
1522                 + "The text to be <span>tested</span></label>");
1523     }
1524 
1525     /**
1526      * Verifies getInnerText().
1527      * @throws Exception if the test fails
1528      */
1529     @Test
1530     @Alerts("A \u00A0 nbsp and spaces")
1531     public void getInnerTextParagraphNbsp() throws Exception {
1532         getInnerTextFormated("<p id='tester'>A &nbsp; nbsp and spaces</p>");
1533     }
1534 
1535     /**
1536      * Verifies getInnerText().
1537      * @throws Exception if the test fails
1538      */
1539     @Test
1540     @Alerts("A \u00A0 nbsp and spaces")
1541     public void getInnerTextParagraphNbspNormal() throws Exception {
1542         getInnerTextFormated("<p id='tester' style='white-space: normal'>"
1543                 + "A &nbsp; nbsp and spaces</p>");
1544     }
1545 
1546     /**
1547      * Verifies getInnerText().
1548      * @throws Exception if the test fails
1549      */
1550     @Test
1551     @Alerts("A \u00A0 nbsp and spaces")
1552     public void getInnerTextParagraphNbspNowrap() throws Exception {
1553         getInnerTextFormated("<p id='tester' style='white-space: nowrap'>"
1554                 + "A &nbsp; nbsp and spaces</p>");
1555     }
1556 
1557     /**
1558      * Verifies getInnerText().
1559      * @throws Exception if the test fails
1560      */
1561     @Test
1562     @Alerts("A \u00A0 nbsp and spaces")
1563     public void getInnerTextParagraphNbspPre() throws Exception {
1564         getInnerTextFormated("<p id='tester' style='white-space: pre'>"
1565                 + "A &nbsp; nbsp and spaces</p>");
1566     }
1567 
1568     /**
1569      * Verifies getInnerText().
1570      * @throws Exception if the test fails
1571      */
1572     @Test
1573     @Alerts("A \u00A0 nbsp and spaces")
1574     public void getInnerTextParagraphNbspPreWrap() throws Exception {
1575         getInnerTextFormated("<p id='tester' style='white-space: pre-wrap'>"
1576                 + "A &nbsp; nbsp and spaces</p>");
1577     }
1578 
1579     /**
1580      * Verifies getInnerText().
1581      * @throws Exception if the test fails
1582      */
1583     @Test
1584     @Alerts("A \u00A0 nbsp and spaces")
1585     public void getInnerTextParagraphNbspPreLine() throws Exception {
1586         getInnerTextFormated("<p id='tester' style='white-space: pre-line'>"
1587                 + "A &nbsp; nbsp and spaces</p>");
1588     }
1589 
1590     /**
1591      * Verifies getInnerText().
1592      * @throws Exception if the test fails
1593      */
1594     @Test
1595     @Alerts("A \u00A0\n\u00A0 NBSPs\u00A0\u00A0")
1596     public void getInnerTextParagraphMultilineNbsp() throws Exception {
1597         getInnerTextFormated("<p id='tester'>A &nbsp<br />&nbsp NBSPs&nbsp;&nbsp;</p>");
1598     }
1599 
1600     /**
1601      * Verifies getInnerText().
1602      * @throws Exception if the test fails
1603      */
1604     @Test
1605     @Alerts("A \u00A0\n\u00A0 NBSPs\u00A0\u00A0")
1606     public void getInnerTextParagraphMultilineNbspNormal() throws Exception {
1607         getInnerTextFormated("<p id='tester' style='white-space: normal'>"
1608                 + "A &nbsp<br />&nbsp NBSPs&nbsp;&nbsp;</p>");
1609     }
1610 
1611     /**
1612      * Verifies getInnerText().
1613      * @throws Exception if the test fails
1614      */
1615     @Test
1616     @Alerts("A \u00A0\n\u00A0 NBSPs\u00A0\u00A0")
1617     public void getInnerTextParagraphMultilineNbspNowrap() throws Exception {
1618         getInnerTextFormated("<p id='tester' style='white-space: nowrap'>"
1619                 + "A &nbsp<br />&nbsp NBSPs&nbsp;&nbsp;</p>");
1620     }
1621 
1622     /**
1623      * Verifies getInnerText().
1624      * @throws Exception if the test fails
1625      */
1626     @Test
1627     @Alerts("A \u00A0\n\u00A0 NBSPs\u00A0\u00A0")
1628     public void getInnerTextParagraphMultilineNbspPre() throws Exception {
1629         getInnerTextFormated("<p id='tester' style='white-space: pre'>"
1630                 + "A &nbsp<br />&nbsp NBSPs&nbsp;&nbsp;</p>");
1631     }
1632 
1633     /**
1634      * Verifies getInnerText().
1635      * @throws Exception if the test fails
1636      */
1637     @Test
1638     @Alerts("A \u00A0\n\u00A0 NBSPs\u00A0\u00A0")
1639     public void getInnerTextParagraphMultilineNbspPreWrap() throws Exception {
1640         getInnerTextFormated("<p id='tester' style='white-space: pre-wrap'>"
1641                 + "A &nbsp<br />&nbsp NBSPs&nbsp;&nbsp;</p>");
1642     }
1643 
1644     /**
1645      * Verifies getInnerText().
1646      * @throws Exception if the test fails
1647      */
1648     @Test
1649     @Alerts("A \u00A0\n\u00A0 NBSPs\u00A0\u00A0")
1650     public void getInnerTextParagraphMultilineNbspPreLine() throws Exception {
1651         getInnerTextFormated("<p id='tester' style='white-space: pre-line'>"
1652                 + "A &nbsp<br />&nbsp NBSPs&nbsp;&nbsp;</p>");
1653     }
1654 
1655     /**
1656      * Verifies getInnerText() for issue #128
1657      * (https://github.com/HtmlUnit/htmlunit/issues/128).
1658      * @throws Exception if the test fails
1659      */
1660     @Test
1661     @Alerts("I have  out of 2 stamps")
1662     @HtmlUnitNYI(CHROME = "I have out of 2 stamps",
1663             EDGE = "I have out of 2 stamps",
1664             FF = "I have out of 2 stamps",
1665             FF_ESR = "I have out of 2 stamps")
1666     public void getInnerTextInputInsideP() throws Exception {
1667         getInnerTextFormated("<p id='tester'>"
1668                 + " I have <input type='number' value='2'/> out of 2 stamps</p>");
1669     }
1670 
1671     /**
1672      * @throws Exception if the test fails
1673      */
1674     @Test
1675     @Alerts("Sum")
1676     public void getInnerTextDetails() throws Exception {
1677         getInnerTextFormated("<details id='tester'>"
1678                 + "<summary>Sum</summary>"
1679                 + "<p>detail</p>"
1680                 + "</details>");
1681     }
1682 
1683     /**
1684      * @throws Exception if the test fails
1685      */
1686     @Test
1687     @Alerts("Sum")
1688     @HtmlUnitNYI(CHROME = "SumSum2",
1689             EDGE = "SumSum2",
1690             FF = "SumSum2",
1691             FF_ESR = "SumSum2")
1692     public void getInnerTextDetailsTwoSums() throws Exception {
1693         getInnerTextFormated("<details id='tester'>"
1694                 + "<summary>Sum</summary>"
1695                 + "<summary>Sum2</summary>"
1696                 + "<p>detail</p>"
1697                 + "</details>");
1698     }
1699 
1700     /**
1701      * @throws Exception if the test fails
1702      */
1703     @Test
1704     @Alerts("Sum\n\ndetail")
1705     @HtmlUnitNYI(CHROME = "Sum\ndetail",
1706             EDGE = "Sum\ndetail",
1707             FF = "Sum\ndetail",
1708             FF_ESR = "Sum\ndetail")
1709     public void getInnerTextDetailsOpen() throws Exception {
1710         getInnerTextFormated("<details id='tester' open=true>"
1711                 + "<summary>Sum</summary>"
1712                 + "<p>detail</p>"
1713                 + "</details>");
1714     }
1715 
1716     private void getInnerTextFormated(final String htmlTesterSnipped) throws Exception {
1717         final String htmlContent = DOCTYPE_HTML
1718             + "<html>\n"
1719             + "<head></head>\n"
1720             + "<body>\n"
1721             + "  " + htmlTesterSnipped + "\n"
1722             + "</body></html>";
1723 
1724         final WebDriver driver = loadPage2(htmlContent);
1725         final String text = (String) ((JavascriptExecutor) driver)
1726                 .executeScript("return document.getElementById('tester').innerText");
1727         assertEquals(getExpectedAlerts()[0], text);
1728     }
1729 
1730     private void getOuterTextFormated(final String htmlTesterSnipped) throws Exception {
1731         final String htmlContent = DOCTYPE_HTML
1732             + "<html>\n"
1733             + "<head></head>\n"
1734             + "<body>\n"
1735             + "  " + htmlTesterSnipped + "\n"
1736             + "</body></html>";
1737 
1738         final WebDriver driver = loadPage2(htmlContent);
1739         final String text = (String) ((JavascriptExecutor) driver)
1740                 .executeScript("return document.getElementById('tester').outerText");
1741         assertEquals(getExpectedAlerts()[0], "" + text);
1742     }
1743 
1744     /**
1745      * @throws Exception if the test fails
1746      */
1747     @Test
1748     @Alerts("xy")
1749     public void getVisibleNumberInputValidNumber() throws Exception {
1750         getInnerTextFormatedAfterTyping("<p id='tester'>x<input id='inpt' type='number' value=''/>y</p>", "12");
1751     }
1752 
1753     /**
1754      * @throws Exception if the test fails
1755      */
1756     @Test
1757     @Alerts("xy")
1758     public void getVisibleNumberInputInvalidNumber() throws Exception {
1759         getInnerTextFormatedAfterTyping("<p id='tester'>x<input id='inpt' type='number' value=''/>y</p>", "ab");
1760     }
1761 
1762     private void getInnerTextFormatedAfterTyping(final String htmlTesterSnipped,
1763                         final String... typed) throws Exception {
1764         final String htmlContent = DOCTYPE_HTML
1765             + "<html>\n"
1766             + "<head></head>\n"
1767             + "<body>\n"
1768             + "  " + htmlTesterSnipped + "\n"
1769             + "</body></html>";
1770 
1771         final WebDriver driver = loadPage2(htmlContent);
1772 
1773         final WebElement input = driver.findElement(By.id("inpt"));
1774         for (final String string : typed) {
1775             input.sendKeys(string);
1776         }
1777 
1778         final String text = (String) ((JavascriptExecutor) driver)
1779                 .executeScript("return document.getElementById('tester').innerText");
1780         assertEquals(getExpectedAlerts()[0], text);
1781     }
1782 
1783     /**
1784      * @throws Exception if the test fails
1785      */
1786     @Test
1787     @Alerts("text")
1788     public void getInnerTextWithScript() throws Exception {
1789         getInnerTextFormated("<div id='tester'>"
1790                 + "text"
1791                 + "<script>var x = 'invisible';</script>"
1792                 + "</div>");
1793     }
1794 
1795     /**
1796      * @throws Exception if the test fails
1797      */
1798     @Test
1799     @Alerts("xz")
1800     public void getInnerTextWithTitle() throws Exception {
1801         getInnerTextFormated("<div id='tester'>"
1802                 + "x<title>y</title>z"
1803                 + "</div>");
1804     }
1805 
1806     /**
1807      * @throws Exception if the test fails
1808      */
1809     @Test
1810     @Alerts("y")
1811     public void getInnerTextTitle() throws Exception {
1812         getInnerTextFormated("<div>"
1813                 + "x<title id='tester'>y</title>z"
1814                 + "</div>");
1815     }
1816 
1817     /**
1818      * @throws Exception if the test fails
1819      */
1820     @Test
1821     @Alerts("y")
1822     public void getInnerTextTitleInHead() throws Exception {
1823         final String htmlContent = DOCTYPE_HTML
1824             + "<html>\n"
1825             + "<head id='tester'><title>y</title></head>\n"
1826             + "<body>\n"
1827             + "</body></html>";
1828 
1829         final WebDriver driver = loadPage2(htmlContent);
1830 
1831         final String text = (String) ((JavascriptExecutor) driver)
1832                 .executeScript("return document.getElementById('tester').innerText");
1833         assertEquals(getExpectedAlerts()[0], text);
1834     }
1835 
1836     /**
1837      * @throws Exception if the test fails
1838      */
1839     @Test
1840     @Alerts("text")
1841     public void getOuterTextWithScript() throws Exception {
1842         getOuterTextFormated("<div id='tester'>"
1843                 + "text"
1844                 + "<script>var x = 'invisible';</script>"
1845                 + "</div>");
1846     }
1847 }