use of ru.yandex.qatools.ashot.Screenshot in project ashot by yandex-qatools.
the class DifferTest method testIgnoredCoordsNotSame.
@Test
public void testIgnoredCoordsNotSame() throws Exception {
Screenshot a = createScreenshotWithIgnoredAreas(IMAGE_A_SMALL, new HashSet<>(asList(new Coords(55, 55))));
Screenshot b = createScreenshotWithIgnoredAreas(IMAGE_B_SMALL, new HashSet<>(asList(new Coords(80, 80))));
ImageDiff diff = imageDiffer.makeDiff(a, b);
assertThat(diff.getMarkedImage(), ImageTool.equalImage(loadImage("img/expected/ignore_coords_not_same.png")));
}
use of ru.yandex.qatools.ashot.Screenshot in project ashot by yandex-qatools.
the class DefaultCropper method cropScreenshot.
@Override
public Screenshot cropScreenshot(BufferedImage image, Set<Coords> coordsToCompare) {
Coords cropArea = Coords.unity(coordsToCompare);
Coords imageIntersection = Coords.ofImage(image).intersection(cropArea);
if (imageIntersection.isEmpty()) {
return new Screenshot(image);
}
BufferedImage cropped = new BufferedImage(imageIntersection.width, imageIntersection.height, image.getType());
Graphics g = cropped.getGraphics();
g.drawImage(image, 0, 0, imageIntersection.width, imageIntersection.height, cropArea.x, cropArea.y, cropArea.x + imageIntersection.width, cropArea.y + imageIntersection.height, null);
g.dispose();
Screenshot screenshot = new Screenshot(cropped);
screenshot.setOriginShift(cropArea);
screenshot.setCoordsToCompare(setReferenceCoords(screenshot.getOriginShift(), coordsToCompare));
return screenshot;
}
use of ru.yandex.qatools.ashot.Screenshot in project ashot by yandex-qatools.
the class ScalingDecoratorTest method testDpr.
@SuppressWarnings("UnusedDeclaration")
@Test
public void testDpr() throws Exception {
ShootingStrategy dpr2Strategy = new ScalingDecorator(new SimpleShootingStrategy()).withDpr(2);
Screenshot screenshot = new AShot().shootingStrategy(dpr2Strategy).takeScreenshot(getDriver());
assertThat(screenshot.getImage(), ImageTool.equalImage(loadImage("img/expected/dpr.png")));
}
use of ru.yandex.qatools.ashot.Screenshot in project ashot by yandex-qatools.
the class SerializeScreenshotTest method serializeWithIgnoredAreas.
@Test
public void serializeWithIgnoredAreas() throws IOException, ClassNotFoundException {
Screenshot screenshot = new Screenshot(IMAGE_A_SMALL);
screenshot.setIgnoredAreas(IGNORED_AREAS);
try (ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream(serializedFile))) {
objectOutputStream.writeObject(screenshot);
}
try (ObjectInputStream objectInputStream = new ObjectInputStream(new FileInputStream(serializedFile))) {
Screenshot deserialized = (Screenshot) objectInputStream.readObject();
checkDeserializedScreenshot(screenshot, deserialized);
}
}
use of ru.yandex.qatools.ashot.Screenshot in project selenium_java by sergueik.
the class VisualTest method imageResizeTest.
@Test(enabled = true)
public void imageResizeTest() throws Exception {
// Handle popup
handlePopup(".ui-dialog-titlebar-close");
// Close banner
closeBanner();
WebElement uzmanPhotoSection = driver.findElement(By.cssSelector(".item.uzman>a"));
// Unhide Text which is changing A lot
unhideElement("document.getElementsByClassName('count')[0].style.display='none';");
// Move To Operation
moveToElement(uzmanPhotoSection);
// Wait for 2 second for violet color animation
Thread.sleep(2000);
Screenshot screenShot = takeScreenshot(uzmanPhotoSection);
takeScreenshotOfWebelement(driver, uzmanPhotoSection, testScreenShotDirectory + "\\" + "test.png");
writeScreenshotToFolder(screenShot);
// Resize
resizeImagesWithImageMagick(screenshotPath);
}
Aggregations