1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.htmlunit.html;
16
17 import org.htmlunit.WebDriverTestCase;
18 import org.htmlunit.junit.BrowserRunner;
19 import org.htmlunit.junit.annotation.Alerts;
20 import org.junit.Test;
21 import org.junit.runner.RunWith;
22 import org.openqa.selenium.WebDriver;
23 import org.openqa.selenium.htmlunit.HtmlUnitDriver;
24
25
26
27
28
29
30
31
32 @RunWith(BrowserRunner.class)
33 public class HtmlBreakTest extends WebDriverTestCase {
34
35
36
37
38 @Test
39 @Alerts("[object HTMLBRElement]")
40 public void simpleScriptable() throws Exception {
41 final String html = DOCTYPE_HTML
42 + "<html><head>\n"
43 + "<script>\n"
44 + LOG_TITLE_FUNCTION
45 + " function test() {\n"
46 + " log(document.getElementById('myId'));\n"
47 + " }\n"
48 + "</script>\n"
49 + "</head><body onload='test()'>\n"
50 + " <br id='myId'>\n"
51 + "</body></html>";
52
53 final WebDriver driver = loadPageVerifyTitle2(html);
54 if (driver instanceof HtmlUnitDriver) {
55 final HtmlPage page = (HtmlPage) getEnclosedPage();
56 assertTrue(HtmlBreak.class.isInstance(page.getHtmlElementById("myId")));
57 }
58 }
59
60
61
62
63 @Test
64 public void asNormalizedText() throws Exception {
65 final String html = DOCTYPE_HTML
66 + "<html><head>\n"
67 + "</head><body>\n"
68 + "Hello<br/>world\n"
69 + "</body></html>";
70
71 final WebDriver driver = loadPage2(html);
72 if (driver instanceof HtmlUnitDriver) {
73 final HtmlPage page = (HtmlPage) getEnclosedPage();
74 assertEquals("Hello\nworld", page.getBody().asNormalizedText());
75 }
76 }
77 }