我尝试在测试失败时截取屏幕截图。我可以在ios设备上截取屏幕截图,但不能在Android设备上截屏。 它失败并出现以下错误:
[MJSONWP] Encountered internal error running command: Error: Unsupported MIME type:
at Jimp.throwError (/usr/local/lib/node_modules/appium/node_modules/jimp/index.js:82:43)
at Jimp.parseBitmap (/usr/local/lib/node_modules/appium/node_modules/jimp/index.js:307:31)
at /usr/local/lib/node_modules/appium/node_modules/jimp/index.js:200:29
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)
它曾经在appium 1.4.16上工作。现在我在app 1.6.0 这是我的代码:
public static String captureScreenshot(AppiumDriver driver, String screenshotName){
try {
TakesScreenshot ts = driver;
File source = ts.getScreenshotAs(OutputType.FILE);
String dest = "/Users/automation/Desktop/Reports/" +screenshotName+".png";
File destination = new File(dest);
FileUtils.copyFile(source,destination);
System.out.println("Screenshot was taken");
return dest;
} catch (IOException e) {
Log.report("Exception while taking the screenshot");
return e.getMessage();
}
}
}
任何想法如何解决这个问题?
感谢