MCPcopy Index your code
hub / github.com/HtmlUnit/htmlunit / xpath1

Method xpath1

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

Regression test for Bug #764. Originally located in org.htmlunit.xml.XmlPageTest. @throws Exception if an error occurs

()

Source from the content-addressed store, hash-verified

39 * @throws Exception if an error occurs
40 */
41 @Test
42 public void xpath1() throws Exception {
43 final String html
44 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
45 + "<!DOCTYPE html PUBLIC \n"
46 + " \"-//W3C//DTD XHTML 1.0 Strict//EN\" \n"
47 + " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
48 + "<html xmlns='http://www.w3.org/1999/xhtml' xmlns:xhtml='http://www.w3.org/1999/xhtml'>\n"
49 + "<body><DIV>foo</DIV></body>\n"
50 + "</html>";
51
52 final WebClient client = getWebClient();
53 final List<String> actual = new ArrayList<>();
54 client.setAlertHandler(new CollectingAlertHandler(actual));
55
56 final MockWebConnection conn = new MockWebConnection();
57 conn.setResponse(URL_FIRST, html, MimeType.TEXT_XML);
58 client.setWebConnection(conn);
59
60 final XHtmlPage page = client.getPage(URL_FIRST);
61 final DomNode body = page.getDocumentElement().getFirstChild().getNextSibling();
62 final DomNode div = body.getFirstChild();
63
64 assertEquals(HtmlBody.class, body.getClass());
65 assertEquals("body", body.getLocalName());
66 assertEquals("DIV", div.getLocalName());
67 assertNotNull(page.getFirstByXPath(".//xhtml:body"));
68 assertNotNull(page.getFirstByXPath(".//xhtml:DIV"));
69 assertNull(page.getFirstByXPath(".//xhtml:div"));
70 }
71
72 /**
73 * Tests a simplified real-life response from Ajax4jsf. Originally located in

Callers

nothing calls this directly

Calls 14

setAlertHandlerMethod · 0.95
setResponseMethod · 0.95
setWebConnectionMethod · 0.95
getPageMethod · 0.95
getFirstChildMethod · 0.95
getLocalNameMethod · 0.95
assertNotNullMethod · 0.80
assertNullMethod · 0.80
getWebClientMethod · 0.65
getNextSiblingMethod · 0.45
getDocumentElementMethod · 0.45
assertEqualsMethod · 0.45

Tested by

no test coverage detected