Appium unable to take screenshot on xCode 13.3 and iOS 15.4

3.4k views Asked by At

I woke a few days ago to run an appium UI automated test on iOS simulator which has been running perfectly without any error. I recently upgraded to iOS 15.4 and iOS 13.3 and to my surprise Appium is unable to take screenshots again. I tried checking what the cause could be and found exact similar problem posted here Socket hang up error while taking screenshot in appium (iOS 15.4 beta & xCode 13.3 beta 2). I find this as well on Apple post Xcode 12 Beta 3 Release Notes. Are there any workaround presently for this?

This is the error I'm getting

[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
2

There are 2 answers

0
Toma Lazarov On BEST ANSWER

Change back to iOS 15.2 I had the same issue and struggled for hours... tried everything.. It was absolutely the same case as yours. Yesterday it was working and suddenly today it stopped working. So at the end, the only change was that the xcode simulator updated itself to iOS 15.4 from 15.2. That's why somehow appium inspector stopped working and taking screenshots. I guess it will take some time from appium side things to be updated but until then just row back to latest stable iOS simulator version 15.2. How to do that - Xcode -> Preferences -> Components -> select older iOS version Simulator -> download, Check and Install now -> build -> voila :)

0
Mārtiņš Kristaps Mickus On

It can be fixed by changing WebDriverAgentLib/Utilities/FBScreenshot.m (257th line):

(nullable id)screenshotRequestWithScreenID:(unsigned int)screenID

to:

(nullable id)screenshotRequestWithScreenID:(long long)screenID

Problem is reported and it’s solution is also here: https://github.com/appium/appium/issues/16604