Regression test for Bug #764. Originally located in org.htmlunit.xml.XmlPageTest. @throws Exception if an error occurs
()
| 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 |
nothing calls this directly
no test coverage detected