MCPcopy Create free account
hub / github.com/HtmlUnit/htmlunit / xpath2

Method xpath2

src/test/java/org/htmlunit/html/XHtmlPageTest.java:97–121  ·  view source on GitHub ↗

@throws Exception if an error occurs

()

Source from the content-addressed store, hash-verified

95 * @throws Exception if an error occurs
96 */
97 @Test
98 public void xpath2() throws Exception {
99 final String html =
100 "<html xmlns='http://www.w3.org/1999/xhtml' xmlns:xhtml='http://www.w3.org/1999/xhtml'>\n"
101 + "<body><xhtml:div>foo</xhtml:div></body></html>";
102
103 final MockWebConnection conn = new MockWebConnection();
104 conn.setDefaultResponse(html, 200, "OK", "application/xhtml+xml");
105
106 final WebClient client = getWebClient();
107 client.setWebConnection(conn);
108 final XHtmlPage page = client.getPage(URL_FIRST);
109
110 assertEquals(1, page.getByXPath("//:body").size());
111 assertEquals(0, page.getByXPath("//:BODY").size());
112 assertEquals(0, page.getByXPath("//:bOdY").size());
113
114 assertEquals(1, page.getByXPath("//xhtml:body").size());
115 assertEquals(0, page.getByXPath("//xhtml:BODY").size());
116 assertEquals(0, page.getByXPath("//xhtml:bOdY").size());
117
118 assertEquals(1, page.getByXPath("//xhtml:div").size());
119 assertEquals(0, page.getByXPath("//xhtml:DIV").size());
120 assertEquals(0, page.getByXPath("//xhtml:dIv").size());
121 }
122
123 /**
124 * @throws Exception if an error occurs

Callers

nothing calls this directly

Calls 7

setDefaultResponseMethod · 0.95
setWebConnectionMethod · 0.95
getPageMethod · 0.95
getWebClientMethod · 0.65
assertEqualsMethod · 0.45
sizeMethod · 0.45
getByXPathMethod · 0.45

Tested by

no test coverage detected