java - Appium - 我在截屏时收到空消息
问题描述
我是自动化新手。我在截屏时收到空消息。
TestNG 监听器代码
@Override
public void onTestFailure(ITestResult arg0) {
//write screenshot codes here
String s=arg0.getName();
try {
Base.getScreenshot(s);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
基类截图方法
public static void getScreenshot(String s) throws IOException
{
try{
File src = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
// Copy files to specific location
// arg0.getName() will return name of test case so that screenshot name will be same as test case name
FileUtils.copyFile(src, new File(System.getProperty("user.dir")+"\\"+s+".png"));
System.out.println("Successfully captured a screenshot");
}catch (Exception e){
System.out.println("Exception while taking screenshot "+e.getMessage());
}
}
我使用一些不正确的定位器手动失败了测试来调用tentNG失败,并且在截取屏幕截图时它检索到如下的空消息
输出:截屏时出现异常 null
请问谁能帮我解决这个问题?
我现在被屏蔽了:(
解决方案
推荐阅读
- python - OpenCV:MatchShapes 完全错误
- r - 将因子的每个重复标记为新列中的相同数字,以跨因子水平出现的顺序
- powerbi - 一种 Power BI 度量,显示季度是实际季度还是估计季度
- angular - SpeechSynthesis 在 CEF 中不起作用 - 铬嵌入式框架
- c++ - 当 std::vector push_back() 具有引用成员的对象
- html - 单击链接时避免固定标题的部分重叠:绘制顺序问题
- javascript - 如何将 MVC 数据绑定到 Plotly
- python - python 3 pyautogui.click() 被非活动应用程序“阻止”
- scala - Scala 泛型类型约束和特殊行为
- qt - 如何禁用 Qt 按钮标签上的 & 特殊处理?