Sikuli Image Testing

This demo will show the use of Sikuli as a means of testing for an image on a web page and clicking on that image. WebDriver is used for navigation till you start seeing red boxes on the screen. The highlight feature was used to generate a red box around the found regions.

  • Open Wikipedia website
  • Navigate to Hippo page
  • Check for Wiki Logo
  • Check for Hippo thumbnail
  • Click  Hippo thumbnail

 

NOTE: The test execution has been slowed down for demo purposes

Example Code:

 
package com.demo.test;

public class WikipediaSikuliTest extends BaseTest {

    private WikipediaPage wikiPage;
    private HippoWikiPage hippoPage;

    private final Screen screen = new Screen();

    public Screen getScreen() {
        return screen;
    }

 ...

    @Test
    public void shouldBeOnHippoPage() throws FindFailed {
        hippoPage.get();
        Assert.assertEquals(getWebDriver().getCurrentUrl(), "http://en.wikipedia.org/wiki/Hippo", "Browser should be on Hippopotamus wikipedia page");
        Assert.assertTrue(hippoPage.getPageSource().contains("Taxonomy"), "Taxonomy Should be on the page");

        Sleeper.sleepTight(CosConstant.LARGE_DELAY);

        Region region1 = getScreen().find("src/test/resources/com/creative/oss/images/wiki-test-image.png");
        region1.highlight(5.0f);

        Region hippoThumbnail = getScreen().find("src/test/resources/com/creative/oss/images/wiki-test-image3.png");
        hippoThumbnail.highlight(5.0f);

        getScreen().click(hippoThumbnail);

        Sleeper.sleepTight(CosConstant.LARGE_DELAY * 3);

    }
}

Leave a Reply

Download and extend ATF...

ATF Is Now Open Source

Join this 10 week program anytime...

DevOps Mastery Program

Get your DevOps health check now...

Free DevOps Assessment

X