}
@Test
public void testGallery() throws FailingHttpStatusCodeException, MalformedURLException, IOException, InterruptedException {
final HtmlPage page = webClient.getPage("http://localhost:8080/photark/");
final HtmlTable table = page.getHtmlElementById("tableGallery");
//testing the static part of the gallery
final String pageAsXml = page.asXml();
assertTrue(pageAsXml.contains("<a href=\"javascript:displayGallery()\" onmouseover=\"document.index.src=index_on.src\" onmouseout=\"document.index.src=index_off.src\" onmousedown=\"beforeClick();\">"));
assertTrue(pageAsXml.contains("<body onload=\"initGallery()\">"));
final String pageAsText = page.asText();
assertTrue(pageAsText.contains("Apache PhotArk Gallery"));
Thread.sleep(3000);
//testing the dynamic part of the gallery
//albums loaded
assertTrue( table.getRow(1).getCell(0).asText().contains("boston"));
//Gallery pictures loaded
assertTrue( table.getRow(3).getCell(0).asXml().contains("http://localhost:8080/photark/gallery/vegas/dsc00")); //Don't use a specific image
//as we can get <> order in <> OS
//clicking on an image
assertTrue(page.getElementById("albumImage").getAttribute("src").contains("space.gif"));
DomNodeList<HtmlElement> ele= table.getRow(3).getCell(0).getElementsByTagName("a");
final HtmlAnchor anchor =(HtmlAnchor) ele.get(0);
final HtmlPage page2= anchor.click();
Thread.sleep(3000);
//checking whether there are images in the album
assertTrue( page2.getElementById("albumImage").getAttribute("src").contains("/photark/gallery/vegas/dsc00")); //Don't use a specific image