Search in sources :

Example 1 with Screenshot

use of ru.yandex.qatools.ashot.Screenshot in project selenium_java by sergueik.

the class VisualTest method takeScreenshot.

// using ashot
public Screenshot takeScreenshot(WebElement element) {
    Screenshot elementScreenShot = new AShot().takeScreenshot(driver, element);
    /*Screenshot elementScreenShot = new AShot()
		        .coordsProvider(new WebDriverCoordsProvider())
		        .takeScreenshot(driver,element);*/
    System.out.println(String.format("Size: Height: %d Width: %d", elementScreenShot.getImage().getHeight(), elementScreenShot.getImage().getWidth()));
    return elementScreenShot;
}
Also used : AShot(ru.yandex.qatools.ashot.AShot) TakesScreenshot(org.openqa.selenium.TakesScreenshot) Screenshot(ru.yandex.qatools.ashot.Screenshot)

Example 2 with Screenshot

use of ru.yandex.qatools.ashot.Screenshot in project selenium_java by sergueik.

the class VisualTest method imageCompareTest.

@Test(enabled = true)
public void imageCompareTest() 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);
    writeScreenshotToFolder(screenShot);
    doComparison(screenShot);
}
Also used : TakesScreenshot(org.openqa.selenium.TakesScreenshot) Screenshot(ru.yandex.qatools.ashot.Screenshot) WebElement(org.openqa.selenium.WebElement) Test(org.testng.annotations.Test)

Example 3 with Screenshot

use of ru.yandex.qatools.ashot.Screenshot in project ashot by yandex-qatools.

the class CroppersTest method testElementOutsideImageIndentCropper.

@Test
public void testElementOutsideImageIndentCropper() throws Exception {
    Screenshot screenshot = new IndentCropper(10).cropScreenshot(IMAGE_A_SMALL, OUTSIDE_IMAGE);
    assertThat(screenshot.getImage(), ImageTool.equalImage(loadImage("img/expected/outside_ic.png")));
}
Also used : Screenshot(ru.yandex.qatools.ashot.Screenshot) IndentCropper(ru.yandex.qatools.ashot.cropper.indent.IndentCropper) Test(org.junit.Test)

Example 4 with Screenshot

use of ru.yandex.qatools.ashot.Screenshot in project ashot by yandex-qatools.

the class CroppersTest method testElementInsideImageIndentCropperWithFilter.

@Test
public void testElementInsideImageIndentCropperWithFilter() throws Exception {
    Screenshot screenshot = new IndentCropper().addIndentFilter(IndentFilerFactory.blur()).addIndentFilter(IndentFilerFactory.monochrome()).cropScreenshot(IMAGE_A_SMALL, INSIDE_IMAGE);
    assertThat(screenshot.getImage(), ImageTool.equalImage(loadImage("img/expected/inside_icf.png")));
}
Also used : Screenshot(ru.yandex.qatools.ashot.Screenshot) IndentCropper(ru.yandex.qatools.ashot.cropper.indent.IndentCropper) Test(org.junit.Test)

Example 5 with Screenshot

use of ru.yandex.qatools.ashot.Screenshot in project ashot by yandex-qatools.

the class DifferTest method testCoordsToCompareAndIgnoredCombine.

@Test
public void testCoordsToCompareAndIgnoredCombine() throws Exception {
    Screenshot a = createScreenshotWithIgnoredAreas(IMAGE_A_SMALL, new HashSet<>(asList(new Coords(60, 60))));
    a.setCoordsToCompare(new HashSet<>(asList(new Coords(50, 50, 100, 100))));
    Screenshot b = createScreenshotWithIgnoredAreas(IMAGE_B_SMALL, new HashSet<>(asList(new Coords(80, 80))));
    b.setCoordsToCompare(new HashSet<>(asList(new Coords(50, 50, 100, 100))));
    ImageDiff diff = imageDiffer.makeDiff(a, b);
    assertThat(diff.getMarkedImage(), ImageTool.equalImage(loadImage("img/expected/combined_diff.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)

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