我正在使用Xamarin.UITest在Android模拟器上运行测试。测试成功运行,但所需文件夹中没有屏幕截图文件。日志文件中有一条错误消息:
12:12:03 E/Screenshot: Unsupported protocol: 2
Could not take screenshot
java.lang.NullPointerException
at sh.calaba.screenshot.ScreenshotTaker.saveImage(Unknown Source)
at sh.calaba.screenshot.ScreenshotTaker.takeScreenshot(Unknown Source)
at sh.calaba.screenshot.ScreenshotTaker.main(Unknown Source)
04-07-2018 12:12:03.738 +03:00 - 9038 - Took screenshot. { Path: "C:\Source\Repos\MyApp\MyApp.UITests\bin\Release\screenshot-1.png", Title: "Welcome screen." }
初始化:
return ConfigureApp
.Android
.EnableLocalScreenshots()
.ApkFile("../../../MyApp.Android/bin/Release/com.myapp.MyApp-Signed.apk")
.StartApp();
测试:
AppResult[] results = app.WaitForElement(c => c.Marked("mainPage"));
app.Screenshot("Welcome screen.");
Assert.IsTrue(results.Any());
这个问题已经解决了最新的Calabash for Android 8.1