Search in sources :

Example 11 with Screenshot

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")));
}
Also used : ImageDiff(ru.yandex.qatools.ashot.comparison.ImageDiff) Screenshot(ru.yandex.qatools.ashot.Screenshot) Coords(ru.yandex.qatools.ashot.coordinates.Coords) Test(org.junit.Test)

Example 12 with Screenshot

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;
}
Also used : Screenshot(ru.yandex.qatools.ashot.Screenshot) Coords.setReferenceCoords(ru.yandex.qatools.ashot.coordinates.Coords.setReferenceCoords) Coords(ru.yandex.qatools.ashot.coordinates.Coords) BufferedImage(java.awt.image.BufferedImage)

Example 13 with 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")));
}
Also used : AShot(ru.yandex.qatools.ashot.AShot) ShootingStrategy(ru.yandex.qatools.ashot.shooting.ShootingStrategy) SimpleShootingStrategy(ru.yandex.qatools.ashot.shooting.SimpleShootingStrategy) SimpleShootingStrategy(ru.yandex.qatools.ashot.shooting.SimpleShootingStrategy) TakesScreenshot(org.openqa.selenium.TakesScreenshot) Screenshot(ru.yandex.qatools.ashot.Screenshot) ScalingDecorator(ru.yandex.qatools.ashot.shooting.ScalingDecorator) Test(org.junit.Test)

Example 14 with Screenshot

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);
    }
}
Also used : FileOutputStream(java.io.FileOutputStream) Screenshot(ru.yandex.qatools.ashot.Screenshot) ObjectOutputStream(java.io.ObjectOutputStream) FileInputStream(java.io.FileInputStream) ObjectInputStream(java.io.ObjectInputStream) Test(org.junit.Test)

Example 15 with Screenshot

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);
}
Also used : TakesScreenshot(org.openqa.selenium.TakesScreenshot) Screenshot(ru.yandex.qatools.ashot.Screenshot) WebElement(org.openqa.selenium.WebElement) Test(org.testng.annotations.Test)

Aggregations

Screenshot (ru.yandex.qatools.ashot.Screenshot)15 Test (org.junit.Test)9 TakesScreenshot (org.openqa.selenium.TakesScreenshot)4 Coords (ru.yandex.qatools.ashot.coordinates.Coords)4 ImageDiff (ru.yandex.qatools.ashot.comparison.ImageDiff)3 FileInputStream (java.io.FileInputStream)2 FileOutputStream (java.io.FileOutputStream)2 ObjectInputStream (java.io.ObjectInputStream)2 ObjectOutputStream (java.io.ObjectOutputStream)2 WebElement (org.openqa.selenium.WebElement)2 Test (org.testng.annotations.Test)2 AShot (ru.yandex.qatools.ashot.AShot)2 Coords.setReferenceCoords (ru.yandex.qatools.ashot.coordinates.Coords.setReferenceCoords)2 IndentCropper (ru.yandex.qatools.ashot.cropper.indent.IndentCropper)2 BufferedImage (java.awt.image.BufferedImage)1 DefaultCropper (ru.yandex.qatools.ashot.cropper.DefaultCropper)1 ScalingDecorator (ru.yandex.qatools.ashot.shooting.ScalingDecorator)1 ShootingStrategy (ru.yandex.qatools.ashot.shooting.ShootingStrategy)1 SimpleShootingStrategy (ru.yandex.qatools.ashot.shooting.SimpleShootingStrategy)1