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.annotation.Alerts;
19 import org.junit.jupiter.api.Test;
20 import org.openqa.selenium.By;
21 import org.openqa.selenium.WebDriver;
22 import org.openqa.selenium.htmlunit.HtmlUnitDriver;
23
24
25
26
27
28
29
30
31 public class HtmlMetaTest extends WebDriverTestCase {
32
33
34
35
36 @Test
37 @Alerts("[object HTMLMetaElement]")
38 public void simpleScriptable() throws Exception {
39 final String html = DOCTYPE_HTML
40 + "<html><head>\n"
41 + "<meta id='m' http-equiv='content-type' content='text/html'>\n"
42 + "<script>\n"
43 + LOG_TITLE_FUNCTION
44 + " function test() {\n"
45 + " log(document.getElementById('m'));\n"
46 + " }\n"
47 + "</script>\n"
48 + "</head><body onload='test()'>\n"
49 + "</body></html>";
50
51 final WebDriver driver = loadPageVerifyTitle2(html);
52 if (driver instanceof HtmlUnitDriver) {
53 final HtmlPage page = (HtmlPage) getEnclosedPage();
54 assertTrue(HtmlMeta.class.isInstance(page.getHtmlElementById("m")));
55 }
56 }
57
58
59
60
61 @Test
62 public void getText() throws Exception {
63 final String html = DOCTYPE_HTML
64 + "<html><head><meta id='m' http-equiv='a' content='b'></head><body></body></html>";
65
66 final WebDriver driver = loadPage2(html);
67 final String text = driver.findElement(By.id("m")).getText();
68 assertEquals("", text);
69 }
70
71
72
73
74 @Test
75 public void isDisplayed() throws Exception {
76 final String html = DOCTYPE_HTML
77 + "<html><head><meta id='m' http-equiv='a' content='b'></head><body></body></html>";
78
79 final WebDriver driver = loadPage2(html);
80 final boolean displayed = driver.findElement(By.id("m")).isDisplayed();
81 assertFalse(displayed);
82 }
83
84 }