首页 > 解决方案 > 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

请问谁能帮我解决这个问题?

我现在被屏蔽了:(

标签: javaseleniumautomationtestngappium

解决方案


推荐阅读