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