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;
}
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;
}
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")));
}
Aggregations