Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not sure how to use ignore element feature #251

Open
qamatters opened this issue Sep 22, 2021 · 0 comments
Open

Not sure how to use ignore element feature #251

qamatters opened this issue Sep 22, 2021 · 0 comments

Comments

@qamatters
Copy link

qamatters commented Sep 22, 2021

I am exploring ashot for visual testing in our project but it seems like this ignore element feature, is not very clear, because of that, we are not able to use it. Let me explain my use case:

I have a webpage where a image appears which I want to exclude.

This is how I am taking screenshot:

public static Screenshot initiateImageCompareWithIgnoringElement() { return new AShot() .addIgnoredElement(By.xpath("//img[@alt = 'Automation']")) // ignored element(s) .takeScreenshot(driver); }

`
@test ()
public void testHomePageIgnoringDynamicContent(Method method) throws Exception {
seleniumBase.launchHomePage();
Thread.sleep(1000*10);
String actualImage = method.getName();
String expectedImage = method.getName();
String diffImage = method.getName();

   Robot robot = new Robot();
    robot.mouseMove(0, 0);

    Screenshot actualScreenshot = RepoPage.initiateImageCompareWithIgnoringElement();
    actualScreenshot.setIgnoredAreas(actualScreenshot.getIgnoredAreas());

    File actualFile = new File(actualDir + actualImage + ".png");
    ImageIO.write(actualScreenshot.getImage(), "png", actualFile);

    Screenshot expectedScreenshot = new Screenshot(ImageIO.read(new File(expectedDir + expectedImage+ ".png")));
    ImageDiff diff = new ImageDiffer().makeDiff(expectedScreenshot,actualScreenshot);

    int size = diff.getDiffSize();
    if (size != 0) {
        File diffFile = new File(markedImagesDir +diffImage+ ".png");
        ImageIO.write(diff.getMarkedImage(), "png", diffFile);
        throw new Exception("There are some bugs on the page");
    }
}

`

May I know what exactly is missing here because as per doc, I dont think, anything else is needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant