Unable to take screenshots for iOS simulator version 12.4 using Appium

I am using Appium automation tool to automate UI testing for mobile app using C#.

Testing environment:

  • XCode - 13.2.1
  • iOS - 12.4
  • Appium 1.22.3
  • Appium.WebDriver - 4.3.2

When I run tests in iOS simulator 15.2, I can take screenshots using Appium without any errors. But in iOS simulator 12.4, I am getting error when taking screenshot.

Error is falling in the below line:

Screenshot screenshot = driver.GetScreenshot();

Error I got in visual studio:

OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL http://127.0.0.1:4723/wd/hub/session/575ce7df-ffbb-4b2e-957c-e7eca7829b75/screenshot timed out after 60 seconds. ----> System.Net.WebException : The operation has timed out.

Appium Error Log:

[debug] [W3C (575ce7df)] Calling AppiumDriver.getScreenshot() with args: [“575ce7df-ffbb-4b2e-957c-e7eca7829b75”] [debug] [XCUITest] Executing command ‘getScreenshot’ [WD Proxy] Error: timeout of 240000ms exceeded

Can anyone help to solve this?
Thanks in Advance.

Apple changed the API for screenshots on iOS about a year ago. You’d have to revert to an earlier version of Xcode and Appium to make this work on such an old iOS version: