Search in sources :

Example 1 with HtmlImage

use of com.gargoylesoftware.htmlunit.html.HtmlImage in project promoted-builds-plugin by jenkinsci.

the class PromotedBuildActionTest method testDeletedPromotionProcess.

@Test
public void testDeletedPromotionProcess() throws Exception {
    FreeStyleProject p = j.createFreeStyleProject();
    JobPropertyImpl base = new JobPropertyImpl(p);
    p.addProperty(base);
    PromotionProcess foo = base.addProcess("foo");
    // promote a build
    FreeStyleBuild b1 = j.assertBuildStatusSuccess(p.scheduleBuild2(0));
    foo.promote(b1, new UserCause(), new ManualPromotionBadge());
    // now delete the promotion process
    p.removeProperty(base);
    p.addProperty(base = new JobPropertyImpl(p));
    assertTrue(base.getActiveItems().isEmpty());
    // make sure that the page renders OK without any error
    HtmlPage page = j.createWebClient().getPage(p);
    List<?> candidates = page.getByXPath("//IMG");
    for (Object candidate : candidates) {
        if (!(candidate instanceof HtmlImage)) {
            continue;
        }
        HtmlImage img = (HtmlImage) candidate;
        try {
            assertEquals("Failed to load " + img.getSrcAttribute(), 200, img.getWebResponse(true).getStatusCode());
        } catch (IOException e) {
            throw new AssertionError("Failed to load " + img.getSrcAttribute());
        }
    }
}
Also used : HtmlImage(com.gargoylesoftware.htmlunit.html.HtmlImage) UserCause(hudson.model.Cause.UserCause) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) FreeStyleBuild(hudson.model.FreeStyleBuild) IOException(java.io.IOException) FreeStyleProject(hudson.model.FreeStyleProject) Test(org.junit.Test)

Example 2 with HtmlImage

use of com.gargoylesoftware.htmlunit.html.HtmlImage in project selenium_java by sergueik.

the class WhenBrowsingReportsList method checkReportIcon.

private void checkReportIcon(final HtmlTableRow row) {
    final HtmlTableCell cell = row.getCell(0);
    final List<HtmlElement> elements = cell.getHtmlElementsByTagName("img");
    Assert.assertEquals("Unexpected number of image elements", 1, elements.size());
    final HtmlImage img = (HtmlImage) elements.get(0);
    final String iconPath = img.getSrcAttribute().toUpperCase();
    Assert.assertTrue("Unexpected report icon: ", iconPath.endsWith("/DOCUMENT.GIF"));
}
Also used : HtmlImage(com.gargoylesoftware.htmlunit.html.HtmlImage) HtmlElement(com.gargoylesoftware.htmlunit.html.HtmlElement) HtmlTableCell(com.gargoylesoftware.htmlunit.html.HtmlTableCell)

Aggregations

HtmlImage (com.gargoylesoftware.htmlunit.html.HtmlImage)2 HtmlElement (com.gargoylesoftware.htmlunit.html.HtmlElement)1 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)1 HtmlTableCell (com.gargoylesoftware.htmlunit.html.HtmlTableCell)1 UserCause (hudson.model.Cause.UserCause)1 FreeStyleBuild (hudson.model.FreeStyleBuild)1 FreeStyleProject (hudson.model.FreeStyleProject)1 IOException (java.io.IOException)1 Test (org.junit.Test)1