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