Error getting screenshot: "Cannot find XCTImageEncoding class"

In some full runs all screenshot taking calls in iOS tests fail with an error below.

The way how the screenshot is take is:
byte[] bites = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES);

the error is
Error getting screenshot: Error Domain=com.facebook.WebDriverAgent Code=1 “Cannot find XCTImageEncoding class”

appium: v2.2.2
XCUITestDriver: v5.8.1
Java client: v8.5.1

Is there any idea what can cause this?

2023-12-17 20:03:21:989 - [XCUITestDriver@6f76 (321fdd97)] Error getting screenshot: Error Domain=com.facebook.WebDriverAgent Code=1 “Cannot find XCTImageEncoding class” UserInfo={NSLocalizedDescription=Cannot find XCTImageEncoding class}
Build info: version: ‘4.11.0’, revision: ‘040bc5406b’
System info: os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.16’, java.version: ‘11.0.2’
Driver info: io.appium.java_client.ios.IOSDriver
Command: [321fdd97-c14f-4cc6-88a7-64a98f66b6ec, screenshot {}]
Capabilities {appium:app: /Users/user/appium/conf…, appium:autoDismissAlerts: false, appium:automationName: XCuiTest, appium:clearSystemFiles: true, appium:databaseEnabled: false, appium:derivedDataPath: /Users/user/Library/Deve…, appium:deviceName: iphone8, appium:includeDeviceCapsToSessionInfo: false, appium:javascriptEnabled: true, appium:locationContextEnabled: false, appium:mjpegServerPort: 9103, appium:networkConnectionEnabled: false, appium:newCommandTimeout: 600, appium:platformVersion: 14.4.2, appium:showIOSLog: false, appium:showXcodeLog: false, appium:takesScreenshot: true, appium:udid: 00000000000000000…, appium:usePrebuiltWDA: true, appium:wdaConnectionTimeout: 600000, appium:wdaLaunchTimeout: 300000, appium:wdaLocalPort: 8103, appium:wdaStartupRetries: 1, appium:webStorageEnabled: false, platformName: IOS}

Try add retry logic while taking screenshot.

iOS below v 15 is not supported by the current driver.
Consider downgrading the driver or upgrading the iOS device

1 Like