Search in sources :

Example 1 with AShot

use of ru.yandex.qatools.ashot.AShot 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 AShot

use of ru.yandex.qatools.ashot.AShot in project carina by qaprosoft.

the class Screenshot method takeFullScreenshot.

/**
 * Makes fullsize screenshot using javascript (May not work properly with
 * popups and active js-elements on the page)
 *
 * @param driver
 *            - webDriver.
 * @param augmentedDriver
 *            - webDriver.
 * @exception IOException
 *
 * @return screenshot image
 */
private static BufferedImage takeFullScreenshot(WebDriver driver, WebDriver augmentedDriver) throws IOException {
    BufferedImage screenShot;
    if (driver.getClass().toString().contains("java_client")) {
        // Mobile Native app
        File screenshot = ((AppiumDriver<?>) driver).getScreenshotAs(OutputType.FILE);
        screenShot = ImageIO.read(screenshot);
    } else if (Configuration.getDriverType().equals(SpecialKeywords.MOBILE)) {
        // Mobile web
        screenShot = ImageIO.read(((TakesScreenshot) augmentedDriver).getScreenshotAs(OutputType.FILE));
    } else {
        // regular web
        ru.yandex.qatools.ashot.Screenshot screenshot = new AShot().shootingStrategy(ShootingStrategies.viewportPasting(100)).takeScreenshot(augmentedDriver);
        screenShot = screenshot.getImage();
    }
    return screenShot;
}
Also used : AShot(ru.yandex.qatools.ashot.AShot) AppiumDriver(io.appium.java_client.AppiumDriver) TakesScreenshot(org.openqa.selenium.TakesScreenshot) File(java.io.File) BufferedImage(java.awt.image.BufferedImage)

Example 3 with AShot

use of ru.yandex.qatools.ashot.AShot 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)

Aggregations

TakesScreenshot (org.openqa.selenium.TakesScreenshot)3 AShot (ru.yandex.qatools.ashot.AShot)3 Screenshot (ru.yandex.qatools.ashot.Screenshot)2 AppiumDriver (io.appium.java_client.AppiumDriver)1 BufferedImage (java.awt.image.BufferedImage)1 File (java.io.File)1 Test (org.junit.Test)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