本文整理汇总了Java中ru.yandex.qatools.ashot.AShot类的典型用法代码示例。如果您正苦于以下问题:Java AShot类的具体用法?Java AShot怎么用?Java AShot使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AShot类属于ru.yandex.qatools.ashot包,在下文中一共展示了AShot类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveFullPageScreenshot
import ru.yandex.qatools.ashot.AShot; //导入依赖的package包/类
@Attachment(value = "Entirepage Screenshot of {0}", type = "image/png")
public static byte[] saveFullPageScreenshot(String name,WebDriver driver)
{
try
{
BufferedImage image = new AShot().shootingStrategy(ShootingStrategies.viewportPasting(1000)).takeScreenshot(driver).getImage();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(image, "png", baos);
baos.flush();
byte[] imageInByte = baos.toByteArray();
baos.close();
return imageInByte;
}
catch (IOException e)
{
e.printStackTrace();
}
return "Unable to Get Screenshot.".getBytes();
}
示例2: excludeAndInclude
import ru.yandex.qatools.ashot.AShot; //导入依赖的package包/类
@Deprecated
/**
* use {@link TeasyScreenshot#excludeAndInclude(List, List)}
*/
public Screenshot excludeAndInclude(List<By> excludeLocators, List<By> includeLocators) {
WebDriver driver = getWebDriver();
AShot aShot = new AShot();
if (isChrome()) {
hideScrollbar(driver);
makeViewPortShootingStrategy(aShot);
}
addIgnoredAreas(excludeLocators, driver, aShot);
addMonochromeIndentFilter(aShot);
Screenshot screenshot = aShot.takeScreenshot(driver, getIncludeElements(includeLocators, driver));
if (isChrome()) {
revealScrollbar(driver);
}
return screenshot;
}
示例3: exclude
import ru.yandex.qatools.ashot.AShot; //导入依赖的package包/类
@Deprecated
/**
* use {@link TeasyScreenshot#exclude(List)}
*/
public Screenshot exclude(List<By> excludeLocators) {
WebDriver driver = getWebDriver();
AShot aShot = new AShot();
if (isChrome()) {
hideScrollbar(driver);
makeViewPortShootingStrategy(aShot);
}
addIgnoredAreas(excludeLocators, driver, aShot);
Screenshot screenshot = aShot.takeScreenshot(driver);
if (isChrome()) {
revealScrollbar(driver);
}
return screenshot;
}
示例4: include
import ru.yandex.qatools.ashot.AShot; //导入依赖的package包/类
@Deprecated
/**
* use {@link TeasyScreenshot#include(List)}
*/
public Screenshot include(List<By> includeLocators) {
WebDriver driver = getWebDriver();
AShot aShot = new AShot();
if (isChrome()) {
hideScrollbar(driver);
makeViewPortShootingStrategy(aShot);
}
addMonochromeIndentFilter(aShot);
Screenshot screenshot = aShot.takeScreenshot(driver, getIncludeElements(includeLocators, driver));
if (isChrome()) {
revealScrollbar(driver);
}
return screenshot;
}
示例5: fullPage
import ru.yandex.qatools.ashot.AShot; //导入依赖的package包/类
@Deprecated
/**
* use {@link TeasyScreenshot#fullPage()}
*/
public Screenshot fullPage() {
WebDriver driver = getWebDriver();
AShot aShot = new AShot();
if (isChrome()) {
hideScrollbar(driver);
makeViewPortShootingStrategy(aShot);
}
Screenshot screenshot = aShot.takeScreenshot(driver);
if (isChrome()) {
revealScrollbar(driver);
}
return screenshot;
}
示例6: takeScreenshot
import ru.yandex.qatools.ashot.AShot; //导入依赖的package包/类
public void takeScreenshot(ScenarioExecutionContext scenarioContext, Action action){
WebDriver driver = scenarioContext.getDriver();
if(driver instanceof TakesScreenshot){
ScenarioExecutionContext scenarioRootContext = scenarioContext.getRoot();
BufferedImage screenshot = new AShot()
.shootingStrategy(getShootingStrategy(scenarioRootContext))
.takeScreenshot(driver).getImage();
String format = getScreenshotFormat(scenarioRootContext);
String targetFileName = getFileName(scenarioRootContext, action, format);
try {
ImageIO.write(screenshot, format, new File(targetFileName));
} catch (IOException e) {
throw new NonReadableFileException(targetFileName, e);
}
}
}
示例7: getScreenShot
import ru.yandex.qatools.ashot.AShot; //导入依赖的package包/类
@Attachment(value = "Page")
public byte[] getScreenShot()
{
ru.yandex.qatools.ashot.Screenshot s = new AShot().takeScreenshot(localDriver);
try
{
ByteArrayOutputStream stream = new ByteArrayOutputStream();
ImageIO.write(s.getImage(), "png", stream);
stream.flush();
byte[] image = stream.toByteArray();
stream.close();
return image;
}
catch (IOException e)
{
e.printStackTrace();
return null;
}
}
示例8: capture
import ru.yandex.qatools.ashot.AShot; //导入依赖的package包/类
@Override
public ICapturable capture(ScreenArea area)
{
try
{
switch (area)
{
case VISIBLE_SCREEN:
screenshot = new AShot().takeScreenshot(driver).getImage();
break;
case FULL_SCREEN:
screenshot = new AShot().shootingStrategy(ShootingStrategies.viewportPasting(100)).takeScreenshot(driver).getImage();
break;
}
}
catch (Exception e)
{
LOGGER.error("Unable to capture screenshot: " + e.getMessage());
}
return this;
}
示例9: addIgnoredAreas
import ru.yandex.qatools.ashot.AShot; //导入依赖的package包/类
private void addIgnoredAreas(List<TeasyElement> excludeElements, AShot aShot) {
for (TeasyElement element : excludeElements) {
Point location = element.getLocation();
Dimension size = element.getSize();
aShot.addIgnoredArea(new Coords(location.getX(), location.getY(), size.getWidth(), size.getHeight()));
}
}
示例10: addIgnoredAreas
import ru.yandex.qatools.ashot.AShot; //导入依赖的package包/类
private void addIgnoredAreas(List<By> excludeLocators, WebDriver driver, AShot aShot) {
for (By excludeLocator : excludeLocators) {
for (WebElement excludeElement : driver.findElements(excludeLocator)) {
aShot.addIgnoredArea(new Coords(excludeElement.getLocation().getX(), excludeElement.getLocation().getY(),
excludeElement.getSize().getWidth(), excludeElement.getSize().getHeight()));
}
}
}
示例11: takeScreenshot
import ru.yandex.qatools.ashot.AShot; //导入依赖的package包/类
/**
* <p>
* Take the screenshot
* </p>
*
* @return
*/
private static String takeScreenshot() {
try {
// now copy the screenshot to desired location using copyFile
Path screenshotFolder;
screenshotFolder = Paths.get(System.getProperty("user.dir"), "output/screenshots");
if (Files.notExists(screenshotFolder))
Files.createDirectory(screenshotFolder);
String fileName = "Screenshot" + "_" + System.nanoTime();
Path screenshotPath = Paths.get(screenshotFolder.toString(), fileName + ".png");
Screenshot screenshot = new AShot()
.takeScreenshot(getDriver());
ImageIO.write(screenshot.getImage(), "PNG", new File(screenshotPath.toString()));
return screenshotPath.toString();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
示例12: getScreenShotFromAShot
import ru.yandex.qatools.ashot.AShot; //导入依赖的package包/类
private File getScreenShotFromAShot(WebDriver driver, ShootingStrategy strategy) throws IOException {
File file = File.createTempFile("screenshot", ".png");
Screenshot screenshot = new AShot().shootingStrategy(strategy)
.takeScreenshot(driver);
ImageIO.write(screenshot.getImage(), "png", file);
return file;
}
示例13: excludeAndInclude
import ru.yandex.qatools.ashot.AShot; //导入依赖的package包/类
public Screenshot excludeAndInclude(List<TeasyElement> excludeElements, List<TeasyElement> includeElements) {
AShot aShot = new AShotChromeDecorator();
addIgnoredAreas(excludeElements, aShot);
addMonochromeIndentFilter(aShot);
return aShot.takeScreenshot(driver, asWebElements(includeElements));
}
示例14: exclude
import ru.yandex.qatools.ashot.AShot; //导入依赖的package包/类
public Screenshot exclude(List<TeasyElement> elements) {
AShot aShot = new AShotChromeDecorator();
addIgnoredAreas(elements, aShot);
return aShot.takeScreenshot(driver);
}
示例15: include
import ru.yandex.qatools.ashot.AShot; //导入依赖的package包/类
public Screenshot include(List<TeasyElement> elements) {
AShot aShot = new AShotChromeDecorator();
addMonochromeIndentFilter(aShot);
return aShot.takeScreenshot(driver, asWebElements(elements));
}