几天前我醒来,在iOS模拟器上运行了一个appium UI自动测试,该测试运行得很完美,没有任何错误。我最近升级到了iOS 15.4和iOS 13.3,令我惊讶的是,Appium无法再次截图。我试着检查原因,在appium(iOS 15.4测试版和xCode 13.3测试版2(中截图时,发现了与此处发布的Socket挂断错误完全类似的问题。我在苹果发布的Xcode 12 Beta 3发行说明中也发现了这一点。目前有什么解决办法吗?
这是我得到的错误
[HTTP] --> GET /wd/hub/session/ea84cef2-3649-4e76-91b9-23cec159e3a1/element/1B000000-0000-0000-1439-000000000000/screenshot
[HTTP] {}
[debug] [W3C (ea84cef2)] Calling AppiumDriver.getElementScreenshot() with args: ["1B000000-0000-0000-1439-000000000000","ea84cef2-3649-4e76-91b9-23cec159e3a1"]
[debug] [XCUITest] Executing command 'getElementScreenshot'
[debug] [WD Proxy] Matched '/element/1B000000-0000-0000-1439-000000000000/screenshot' to command name 'getElementScreenshot'
[debug] [Protocol Converter] Did not know how to rewrite the original URL '/element/1B000000-0000-0000-1439-000000000000/screenshot' for W3C protocol
[debug] [WD Proxy] Proxying [GET /element/1B000000-0000-0000-1439-000000000000/screenshot] to [GET http://127.0.0.1:8100/session/88FE5109-F180-482B-B948-980F345404CC/element/1B000000-0000-0000-1439-000000000000/screenshot] with no body
[WD Proxy] Got response with status 500: {"value":{"error":"unable to capture screen","message":"Error Domain=com.facebook.WebDriverAgent Code=1 "Cannot take a screenshot within 20000 ms timeout" UserInfo={NSLocalizedDescription=Cannot take a screenshot within 20000 ms timeout}","traceback":""},"sessionId":"88FE5109-F180-482B-B948-980F345404CC"}
[debug] [W3C] Matched W3C error code 'unable to capture screen' to UnableToCaptureScreen
[debug] [W3C (ea84cef2)] Encountered internal error running command: UnableToCaptureScreen: Error Domain=com.facebook.WebDriverAgent Code=1 "Cannot take a screenshot within 20000 ms timeout" UserInfo={NSLocalizedDescription=Cannot take a screenshot within 20000 ms timeout}
[debug] [W3C (ea84cef2)] at errorFromW3CJsonCode (/Users/kadeoye/.appium/appium-xcuitest-driver/node_modules/appium-base-driver/lib/protocol/errors.js:780:25)
[debug] [W3C (ea84cef2)] at ProxyRequestError.getActualError (/Users/kadeoye/.appium/appium-xcuitest-driver/node_modules/appium-base-driver/lib/protocol/errors.js:663:14)
[debug] [W3C (ea84cef2)] at JWProxy.command (/Users/kadeoye/.appium/appium-xcuitest-driver/node_modules/appium-base-driver/lib/jsonwp-proxy/proxy.js:272:19)
[debug] [W3C (ea84cef2)] at runMicrotasks (<anonymous>)
[debug] [W3C (ea84cef2)] at processTicksAndRejections (node:internal/process/task_queues:96:5)
[debug] [W3C (ea84cef2)] at XCUITestDriver.proxyCommand (/Users/kadeoye/.appium/appium-xcuitest-driver/node_modules/appium-xcuitest-driver/lib/commands/proxy-helper.js:96:12)
[debug] [W3C (ea84cef2)] at XCUITestDriver.getElementScreenshot (/Users/kadeoye/.appium/appium-xcuitest-driver/node_modules/appium-xcuitest-driver/lib/commands/screenshots.js:52:16)
[HTTP] <-- GET /wd/hub/session/ea84cef2-3649-4e76-91b9-23cec159e3a1/element/1B000000-0000-0000-1439-000000000000/screenshot 500 20106 ms - 1319
改回iOS 15.2我遇到了同样的问题,挣扎了几个小时。。。什么都试过了。。这和你的情况完全一样。昨天它在工作,今天突然停止了工作。所以最后,唯一的变化是xcode模拟器从15.2更新到了iOS 15.4。这就是为什么appium检查员不知何故停止了工作并截屏的原因。我想appium方面的东西需要一些时间才能更新,但在那之前,只需回到最新的稳定iOS模拟器15.2版本如何做到这一点-Xcode->首选项->组件->选择旧的iOS版本模拟器->下载,立即检查并安装->构建->瞧:(
可以通过更改WebDriverAgentLib/Utilities/FBScreenshot.m(第257行(:来修复
(nullable id)screenshotRequestWithScreenID:(unsigned int)screenID
至:
(nullable id)screenshotRequestWithScreenID:(long long)screenID
报告了问题,解决方案也在这里:https://github.com/appium/appium/issues/16604