通过右键单击执行功能时无法使用Ashot捕获完整的屏幕截图

时间:2018-12-23 22:55:48

标签: selenium cucumber-java extentreports selenium-extent-report ashot

我的问题是,当我右键单击功能执行功能并通过跑步类运行时通过时,为什么全屏截图方法会失败?我看到的错误是方法的空指针:

ExtentCucumberFormatter.stepTestThreadLocal.get();

主要方法:

public static void takeFullPageScreenShot (WebDriver driver) throws Exception {
    String screenShotPath = capture(driver);
    Reporter.addScreenCaptureFromPath(screenShotPath);
}

public static String capture(WebDriver driver) throws Exception
{
    String destinationPath;
    String screenShotName = new Date().toString().replace(":","-")+".png";
    Screenshot screenshot = new AShot().shootingStrategy(ShootingStrategies.viewportPasting(1000)).takeScreenshot(driver);
    if(StringUtils.isNotEmpty(Hooks.environmentConfigurations.getScreenshotPath())){
        destinationPath = String.valueOf(new File(Hooks.environmentConfigurations.getScreenshotPath()+ screenShotName));
    }else {
        destinationPath  = System.getProperty("user.dir") + "\\target\\cucumber-reports\\" + screenShotName ;
    }

    ImageIO.write(screenshot.getImage(),"PNG",new File(destinationPath));
    return destinationPath;
}

0 个答案:

没有答案