/** @throws Exception if the test fails */ @Test public void getWebResponse() throws Exception { final HtmlImage htmlimage = getHtmlElementToTest("image1"); final URL url = htmlimage.getPage().getWebResponse().getWebRequest().getUrl(); Assert.assertNull(htmlimage.getWebResponse(false)); final WebResponse resp = htmlimage.getWebResponse(true); Assert.assertNotNull(resp); assertEquals(url.toExternalForm(), resp.getWebRequest().getAdditionalHeaders().get("Referer")); }
/** @throws Exception if the test fails */ @Test public void imageFileSize() throws Exception { final HtmlImage htmlimage = getHtmlElementToTest("image1"); Assert.assertEquals( "Image filesize", 140144, IOUtils.toByteArray(htmlimage.getWebResponse(true).getContentAsStream()).length); }