private void isMapClick( final String imgId, final Boolean samePage, final String urlSuffixClick, final String urlSuffixClickXY) throws Exception { final String htmlContent = "<html><head><title>foo</title></head><body>\n" + "<a href='http://server/foo'>\n" + "<img id='img1' src='foo.png' ismap>\n" + "<img id='img2' src='foo.png'>\n" + "</a>\n" + "<img id='img3' src='foo.png' ismap>\n" + "<img id='img4' src='foo.png'>\n" + "</body></html>"; final HtmlPage page = loadPage(htmlContent); final HtmlImage img = page.getHtmlElementById(imgId); final Page page2 = img.click(); Assert.assertEquals("same page after click", samePage, Boolean.valueOf(page == page2)); if (!samePage.booleanValue()) { assertEquals( "http://server/foo" + urlSuffixClick, page2.getWebResponse().getWebRequest().getUrl()); } final Page page3 = img.click(25, 30); Assert.assertEquals("same page after click(25, 30)", samePage, Boolean.valueOf(page == page3)); if (!samePage.booleanValue()) { assertEquals( "http://server/foo" + urlSuffixClickXY, page3.getWebResponse().getWebRequest().getUrl()); } }
/** * Tests circle radius of percentage value. * * @throws Exception if the test fails */ @Test @NotYetImplemented public void useMapClick_CircleRadiusPercentage() throws Exception { final String htmlContent = "<html><head><title>foo</title></head><body>\n" + "<img id='myImg' src='foo.png' usemap='#map1'>\n" + "<map name='map1'>\n" + "<area href='a.html' shape='rect' coords='5,5,20,20'>\n" + "<area href='b.html' shape='circle' coords='25,10,10%'>\n" + "</map>\n" + "</body></html>"; final HtmlPage page = loadPage(htmlContent); final HtmlImage img = page.getHtmlElementById("myImg"); img.click(0, 0); }
/** @throws Exception if the test fails */ private void useMapClick(final int x, final int y, final String urlSuffix) throws Exception { final String htmlContent = "<html><head><title>foo</title></head><body>\n" + "<img id='myImg' src='foo.png' usemap='#map1'>\n" + "<map name='map1'>\n" + "<area href='a.html' shape='rect' coords='5,5,20,20'>\n" + "<area href='b.html' shape='circle' coords='25,10,10'>\n" + "</map>\n" + "</body></html>"; final HtmlPage page = loadPage(htmlContent); final HtmlImage img = page.getHtmlElementById("myImg"); final Page page2 = img.click(x, y); final URL url = page2.getWebResponse().getWebRequest().getUrl(); assertTrue(url.toExternalForm(), url.toExternalForm().endsWith(urlSuffix)); }