"Fossies" - the Fresh Open Source Software Archive 
Member "selenium-selenium-4.8.1/javascript/atoms/test/text_test.html" (17 Feb 2023, 15872 Bytes) of package /linux/www/selenium-selenium-4.8.1.tar.gz:
The requested HTML page contains a <FORM> tag that is unusable on "Fossies" in "automatic" (rendered) mode so that page is shown as HTML source code syntax highlighting (style:
standard) with prefixed line numbers.
Alternatively you can here
view or
download the uninterpreted source code file.
1 <!DOCTYPE html>
2 <!--
3 Copryight 2012 Software Freedom Conservancy
4 Copyright 2010-2012 WebDriver committers
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17 -->
18 <html>
19 <head>
20 <title>text_test.html</title>
21 <meta charset="UTF-8">
22 <script src="test_bootstrap.js"></script>
23 <script type="text/javascript">
24 goog.require('bot.dom');
25 goog.require('bot.locators');
26 goog.require('goog.testing.jsunit');
27 goog.require('goog.testing.ExpectedFailures');
28 </script>
29
30 <script type="text/javascript">
31
32 function testGetVisibleTextShouldReturnOneLineText() {
33 var text = getVisibleTextByElementId('oneline');
34
35 assertEquals("A single line of text", text);
36 }
37
38 function testGetVisibleTextShouldReturnMultilineText() {
39 var text = getVisibleTextByElementId('multiline');
40
41 assertContains("A div containing", text);
42 assertContains("More than one line of text", text);
43 assertContains("and block level elements", text);
44 }
45
46 function testGetVisibleTextShouldIgnoreScriptElements() {
47 var text = getVisibleTextByElementId('script');
48
49 assertEquals("Some text that contains script tags", text)
50 }
51
52 function testGetVisibleTextShouldIgnoreTitleElements() {
53 var titleElement = bot.locators.findElement({tagName: 'title'});
54 var text = bot.dom.getVisibleText(titleElement);
55
56 assertEquals('', text)
57 }
58
59 function testGetVisibleTextShouldRecursivelyIgnoreTitleElements() {
60 var headElement = bot.locators.findElement({tagName: 'head'});
61 var text = bot.dom.getVisibleText(headElement);
62
63 assertEquals('', text)
64 }
65
66 function testGetVisibleTextShouldRepresentABlockLevelElementAsANewline() {
67 var text = getVisibleTextByElementId('multiline');
68
69 assertStartsWith("A div containing\n", text);
70 assertContains("More than one line of text\n", text);
71 assertEndsWith("and block level elements", text);
72 }
73
74 function testGetVisibleShouldCollapseMultipleWhitespacesIntoASingleSpace() {
75 var text = getVisibleTextByElementId('lotsofspaces');
76
77 assertEquals("This line has lots of spaces.", text)
78 }
79
80 function testGetVisibleTextShouldConvertNonBreakingSpaceInASpaceChar() {
81 var text = getVisibleTextByElementId('nbsp');
82
83 assertEquals("This line has a non-breaking space", text);
84 }
85
86 function testGetVisibleTextShouldNotCollapseNonBreakingSpaces() {
87 var text = getVisibleTextByElementId("nbspandspaces");
88 assertEquals("This line has a non-breaking space and spaces", text);
89 }
90
91 function testGetVisibleTextShouldNotTrimTrailingNonBreakingSpaces() {
92 var text = getVisibleTextByElementId("trailingnbsp");
93 assertEquals("This line has trailing non-breaking spaces ", text);
94 }
95
96 function testGetVisibleTextShouldNotTrimNonBreakingSpacesAtTheEndOfALineInTheMiddleOfText() {
97 var text = getVisibleTextByElementId("multilinetrailingnbsp");
98 assertStartsWith("These lines \n", text);
99 }
100
101 function testGetVisibleTextShouldNotTrimNonBreakingSpacesAtTheStartOfALineInTheMiddleOfText() {
102 var text = getVisibleTextByElementId("multilinetrailingnbsp");
103 assertContains("\n have", text);
104 }
105
106 function testGetVisibleTextShouldNotTrimTrailingNonBreakingSpacesInMultilineText() {
107 var text = getVisibleTextByElementId("multilinetrailingnbsp");
108 assertEndsWith("trailing NBSPs ", text);
109 }
110
111 function testGetVisibleTextInlineElementsShouldNotAffectReturnedText() {
112 var text = getVisibleTextByElementId("inline");
113
114 assertEquals("This line has text within elements that are meant" +
115 " to be displayed inline", text);
116 }
117
118 function testGetVisibleTextShouldReturnTheEntireTextOfInlineElements() {
119 var text = getVisibleTextByElementId("span");
120
121 assertEquals("An inline element", text);
122 }
123
124 function testGetVisibleTextShouldReturnEmptyStringWhenTextIsOnlySpaces() {
125 var text = getVisibleTextByElementId("spaces");
126
127 assertEquals("", text);
128 }
129
130 function testGetVisibleTextShouldReturnEmptyStringWhenTextIsEmpty() {
131 var text = getVisibleTextByElementId("empty");
132
133 assertEquals("", text);
134 }
135
136 function testGetVisibleTextShouldReturnEmptyStringWhenTagIsSelfClosing() {
137 var text = getVisibleTextByElementId("self-closed");
138
139 assertEquals("", text);
140 }
141
142 function testGetVisibleTextShouldNotTrimSpacesWhenLineWraps() {
143 var text = getVisibleTextByElementId("wrappingtd");
144
145 assertEquals("beforeSpace afterSpace", text);
146 }
147
148 function testGetVisibleTextCorrectlyHandlesAnEntireTable() {
149 var text = getVisibleTextByElementId("wrappingtable");
150
151 assertEquals("beforeSpace afterSpace", text);
152 }
153
154 function testGetVisibleTextShouldHandleSiblingBlockLevelElements() {
155 var text = getVisibleTextByElementId("twoblocks");
156
157 assertEquals("Some text\nSome more text", text);
158 }
159
160 function testGetVisibleTextShouldHandleNestedBlockLevelElements() {
161 var text = getVisibleTextByElementId("nestedblocks");
162
163 assertEquals("Cheese\nSome text\nSome more text\nand also\nBrie", text);
164 }
165
166 function testGetVisibleTextShouldHandleWhitespaceInInlineElements() {
167 var text = getVisibleTextByElementId("inlinespan");
168
169 assertEquals("line has text", text);
170 }
171
172 function testGetVisibleTextShouldHandleLackOfSpacesBetweenInlineElements() {
173 var text = getVisibleTextByElementId("inlinenospaces");
174 assertEquals("oooOooo", text);
175 var text2 = getVisibleTextByElementId("inlinenospaces2");
176 assertEquals("A B", text2);
177 }
178
179 function testGetVisibleTextShouldNotAddExtraSpaces() {
180 var text = getVisibleTextByElementId("descartes");
181 var text2 = getVisibleTextByElementId("abc");
182
183 assertEquals("Dubito, ergo cogito, ergo sum.", text);
184 assertEquals("a bc", text2);
185 }
186
187 function testGetVisibleTestGetTextWithLineBreakForInlineElement() {
188 var text = getVisibleTextByElementId("label1");
189 assertContains("foo\nbar", text);
190 }
191
192 function testGetVisibleTextShouldOnlyIncludeVisibleText() {
193 var empty = getVisibleTextByElementId("suppressedParagraph");
194 var explicit = getVisibleTextByElementId("outer");
195
196 assertEquals("", empty);
197 assertEquals("sub-element that is explicitly visible", explicit);
198 }
199
200 function testGetVisibleTextOnAnchorsWithWhitespaces() {
201 var text = getVisibleTextByElementId("links");
202
203 assertEquals("link with leading space " + "link with trailing space " +
204 "link with formatting tags", text);
205 }
206
207 function testGetVisibleTextHandlesTrailingWhitespaces() {
208 var text = getVisibleTextByElementId("trailingSpaces");
209 assertEquals("1 2 3 4", text);
210 }
211
212 function testGetVisibleTextHandlesTrailingBreaks() {
213 var text = getVisibleTextByElementId("trailingBreaks");
214 assertEquals("a\nb", text);
215 }
216
217 function testKeepsNonBreakingSpacesBeforeATag() {
218 var text = getVisibleTextByElementId("id2");
219
220 assertEquals("this is the second element", text);
221 }
222
223 function testRemovesZeroWidthCharacters() {
224 var text = getVisibleTextByElementId("zerowidth");
225
226 assertEquals("This line has a bunch of zero-width characters in it.", text);
227 }
228
229 function testTransparentTextIsIgnored() {
230 var text = getVisibleTextByElementId("opaque");
231
232 assertEquals("Some text", text);
233 }
234
235 function testShouldRetainTheFormattingOfTextWithinAPreElement() {
236 var text = getVisibleTextByElementId("preformatted");
237
238 assertEquals(" This section has a preformatted\n text block \n split in four lines\n ", text);
239 }
240
241 function testShouldRetainTheFormattingOfTextWithinAPreElementThatIsWithinARegularBlock() {
242 var text = getVisibleTextByElementId("div-with-pre");
243
244 assertEquals("before pre\n This section has a preformatted\n text block \n split in four lines\n \nafter pre", text);
245 }
246
247 function testGetVisibleTextShouldHandleCssContentReplacement() {
248 var expect = new goog.testing.ExpectedFailures();
249 expect.expectFailureFor(goog.userAgent.GECKO || goog.userAgent.IE ||
250 goog.userAgent.SAFARI || goog.userAgent.WEBKIT || goog.userAgent.EDGE,
251 "Does not support CSS3 content: 'foo' replacement");
252
253 expect.run(function() {
254 var text = getVisibleTextByElementId("css3-content");
255 assertEquals("PASS", text);
256 });
257 }
258
259 function testGetVisibleTextShouldHandleTextTransformProperty() {
260 var text = getVisibleTextByElementId("capitalized");
261 assertEquals("Hello, World! Bla-Bla-BLA", text);
262 text = getVisibleTextByElementId("lowercased");
263 assertEquals("hello, world! bla-bla-bla", text);
264 text = getVisibleTextByElementId("uppercased");
265 assertEquals("HELLO, WORLD! BLA-BLA-BLA", text);
266
267 text = getVisibleTextByElementId("capitalized-1");
268 assertEquals("Äåìî", text);
269 text = getVisibleTextByElementId("capitalized-2");
270 assertEquals("Manipulowanie Przepływem", text);
271 text = getVisibleTextByElementId("capitalized-3");
272 assertEquals("Manipulowanie Przepływem", text);
273 text = getVisibleTextByElementId("capitalized-4");
274 assertEquals("Manipulowanie Pr0123z4epływem", text);
275 text = getVisibleTextByElementId("capitalized-5");
276 assertEquals("Lorem Ipsum Dolor Sit Amet, Consectetur Adipisicing Elit,", text);
277 text = getVisibleTextByElementId("capitalized-6");
278 assertEquals("Ⓐⓑⓒ (Ⓓⓔⓕ) —Ⓖⓗⓘ— Ⓙkl", text);
279 text = getVisibleTextByElementId("capitalized-7");
280 assertEquals('(This) “Is” [A] –Short– -Test- «For» *The* _Css_ ¿Capitalize? ?¡Transfor', text);
281 text = getVisibleTextByElementId("capitalized-8");
282 assertEquals('The Dutch Word: "Ijsland" Starts With A Digraph', text);
283 }
284
285 function getVisibleTextByElementId(id) {
286 var e = bot.locators.findElement({id: id});
287 return bot.dom.getVisibleText(e);
288 }
289
290 function assertContains(expectedText, text) {
291 assertTrue("Text [" + text + "] does not contain [" + expectedText + "]",
292 text.indexOf(expectedText) >= 0);
293 }
294
295 function assertStartsWith(expectedText, text) {
296 assertTrue("Text [" + text + "] does not start with [" + expectedText +
297 "]", text.indexOf(expectedText) == 0);
298 }
299
300 function assertEndsWith(expectedText, text) {
301 assertTrue("Text [" + text + "] does not end with [" + expectedText + "]",
302 text.lastIndexOf(expectedText) == text.length - expectedText.length);
303 }
304
305 // http://code.google.com/p/selenium/issues/detail?id=1293
306 function testBugExposedByIssue1293() {
307 var spaces = getVisibleTextByElementId('spaces');
308 assertEquals('', spaces);
309
310 var table = getVisibleTextByElementId('wrappingtd');
311 assertEquals('beforeSpace afterSpace', table);
312 }
313 </script>
314
315 <style type="text/css">
316 .transparent {
317 opacity: 0; /* non IE */
318 filter:alpha(opacity=0); /* IE 6+ */
319 }
320 </style>
321
322 </head>
323 <body>
324 <p id="oneline">A single line of text</p>
325
326 <div id="multiline">
327 <div>
328 <p>A div containing</p>
329 More than one line of text<br/>
330
331 <div>and block level elements</div>
332 </div>
333 </div>
334 <span id="span">An inline element</span>
335
336 <p id="lotsofspaces">This line has lots
337
338 of spaces.
339 </p>
340
341 <p id="nbsp">This line has a non-breaking space</p>
342
343 <p id="spaces"> </p>
344
345 <p id="empty"></p>
346
347 <p id="self-closed" />
348
349 <p id="suppressedParagraph" style="display: none">A paragraph suppressed using CSS display=none</p>
350
351 <p id="outer" style="visibility: hidden">A <b id="visibleSubElement" style="visibility: visible">sub-element that is explicitly visible</b> using CSS visibility=visible</p>
352
353 <p id="script">Some text<script>function shouldIgnoreMe() {}</script> that contains script tags</p>
354 <p id="nbspandspaces">This line has a non-breaking space and spaces</p>
355 <p id="trailingnbsp">This line has trailing non-breaking spaces </p>
356 <p id="multilinetrailingnbsp">These lines  <br />  have leading and trailing NBSPs </p>
357 <p id="css3-content" style="content: 'PASS'">FAIL</p>
358
359 <p id="inline">This <span id="inlinespan"> line has <em>text</em> </span> within elements that are meant to be displayed
360 <!-- not as a block but --> inline</p>
361
362 <div id="div-with-pre">
363 <p>before pre</p>
364 <pre id="preformatted"> This section has a preformatted
365 text block
366 split in four lines
367 </pre>
368 <p>after pre</p>
369 </div>
370
371 <div id="twoblocks"><p>Some text</p><p>Some more text</p></div>
372
373 <div id="nestedblocks">Cheese <div><p>Some text</p><div><p>Some more text</p><p>and also</p></div></div>Brie</div>
374
375 <div id="collapsingtext"><span></span><div>Hello, world</div><span></span></div>
376
377 <div id="inlinenospaces">ooo<strong>O</strong>ooo</div>
378 <div id="inlinenospaces2"><span>A <span></span>B</span></div>
379
380 <form action="resultPage.html">
381 <p>
382 <input type="checkbox" id="checkbox1">
383 <label id="label1" for="checkbox1">foo<br />bar</label>
384 </p>
385 </form>
386
387 <div id="links">
388 <a href=""> link with leading space</a>
389 <a href="" id="linkWithTrailingSpace">link with trailing space
390 </a>
391 <a href=""><b>link with formatting tags</b></a>
392 </div>
393 <div id="trailingSpaces">
394 1
395 <a href="">2</a>
396 3
397 <a href="">4</a></div>
398
399 <div id="trailingBreaks">
400 <span>a<br></span><span>b</span>
401 </div>
402
403 <table id="wrappingtable">
404 <tbody>
405 <tr><td id="wrappingtd" style="width: 10px;"><span>beforeSpace</span><span> </span><span>afterSpace</span></td></tr>
406 </tbody>
407 </table>
408
409 <span><strong id="descartes">Dubito, <em>ergo cogito</em>, ergo sum.</strong></span>
410 <span id="abc"><b>a</b> <b>b</b>c</span>
411
412 <a id="id2" >this is the <b>second</b> <span>element</span></a>
413
414 <div id="opaque">Some <span class="transparent">transparent</span> text</div>
415
416 <span id="zerowidth">This line has a bunch of ze​ro-width‎ characters‏ in it.</span>
417
418 <div>
419 <a id="capitalized" style="text-transform: capitalize">hello, world! bla-bla-BLA</a><br/>
420 <a id="lowercased" style="text-transform: lowercase">Hello, world! bla-bla-BLA</a><br/>
421 <a id="uppercased" style="text-transform: uppercase">hello, world! bla-bla-BLA</a><br/>
422 </div>
423
424 <div>
425 <a lang="ru" id="capitalized-1" style="text-transform: capitalize">äåìî</a><br/>
426 <a id="capitalized-2" style="text-transform: capitalize">Manipulowanie przepływem</a><br/>
427 <a id="capitalized-3" style="text-transform: capitalize">manipulowanie przepływem</a><br/>
428 <a id="capitalized-4" style="text-transform: capitalize">Manipulowanie pr0123z4epływem</a><br/>
429 <a id="capitalized-5" style="text-transform: capitalize">Lorem ipsum dolor sit amet, consectetur adipisicing elit,</a><br/>
430 <a id="capitalized-6" style="text-transform: capitalize">ⓐⓑⓒ (ⓓⓔⓕ) —ⓖⓗⓘ— ⓙkl</a><br/>
431 <a id="capitalized-7" style="text-transform: capitalize">(this) “is” [a] –short– -test- «for» *the* _css_ ¿capitalize? ?¡transfor</a><br/>
432 <a id="capitalized-8" style="text-transform: capitalize">The Dutch word: "ijsland" starts with a digraph</a><br/>
433 </div>
434
435 </body>
436 </html>