Screen Shot and Image comparison testing using selenium

preview_player
Показать описание
Screen Shot and Image comparison testing using selenium.In this video we are discussion about snap shot or screen shot and image or logo comparison testing using Selenium and ashot. We can compare company logo or any element image also using ashot . we have used extend reports for comparing actual and expected screenshot and weblement image in the report.We have not used hard assertion because we want to complete execution even though the comparison.
Рекомендации по теме
Комментарии
Автор

Can we validate the only some particular area if thats not an element?

googlywoogly
Автор

Jar required--
<dependency>


<version>1.5.4</version>
</dependency>


Code to take screen shot and compare for whole screen
public boolean compareImage(String ExpectedImage) throws IOException {
Screenshot shot = new
File file = new File(screenShotPath + ExpectedImage + ".png");
// System.out.println(file);
// ImageIO.write(shot.getImage(), "PNG", file);
// Getting Expected Image
BufferedImage expectedImg = ImageIO.read(file);
// Getting Actual Image
BufferedImage actualImg = shot.getImage();
// Image Comparison
ImageDiffer imgDiff = new ImageDiffer();
ImageDiff dif = imgDiff.makeDiff(expectedImg, actualImg);
return dif.hasDiff();
}



code to take webelement image and comparision


public boolean compareElementImage(String ExpectedImage, WebElement logoElemnent) throws IOException {
Screenshot logoElementScreenshot = new AShot().shootingStrategy(ShootingStrategies.viewportPasting(1000)).takeScreenshot(SeleniumUtil.getDriver(), logoElemnent);

File file = new File(screenShotPath + ExpectedImage + ".png");

BufferedImage expectedImg = ImageIO.read(file);
// Getting Actual Image
BufferedImage actualImg =
// Image Comparison
ImageDiffer imgDiff = new ImageDiffer();
ImageDiff dif = imgDiff.makeDiff(expectedImg, actualImg);
return dif.hasDiff();
}

NirajGupta
Автор

can u help integrate this code in testng
how can we connect w u?

dhiel
join shbcf.ru