java - 如何在 Appium 上使用 Jbehave 和 Junit 截屏失败?
问题描述
我在 Appium 上使用 Jbehave 和 Junit。我需要截取失败的屏幕截图并将它们添加到报告中。那么在Appium上使用Jbehave在Junit上截屏的方法是什么?
谢谢 :)
解决方案
您可以使用 getScreenshotAs() 方法。例如:
public void takescreenshot(String message, WebDriver driver) { try {
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
File file = new File("GivethePathto savethescreenshot/screenshot"+message+".png");
FileUtils.copyFile(scrFile,file );
test.addScreenCaptureFromPath(file.getAbsolutePath(), message);
}
catch(Exception e) {
e.printStackTrace();
}
}
推荐阅读
- jenkins - 即使 shell 脚本返回非零值,声明性 Jenkinsfile 也不会退出
- office365 - 如何以编程方式检测 Office 2019?
- .net-core - 使用 EntityFrameworkCore 2.1 在运行时搭建脚手架数据库
- java - 空行从哪里来?如何删除它?- 爪哇
- javascript - 切换选项卡时暂停/恢复 CSS 动画
- jquery - 如何循环选择器?
- javascript - 简单的 javascript 替代密码
- objective-c - Instagram 故事分享无法通过登录页面
- doctrine-query - 具有多个值的参数的学说查询
- python - 如何在我的画布小部件(tkinter)上弹出消息框