[Resolved] Appium tests timing out with Sauce Labs iOS despite no code changes

Hey Team,

I have been working on Appium based test automation suite. I have been successfully able to run automation tests on Sauce labs on iOS & Android with no issues before. But this week, for some reason, the tests on Sauce Labs iOS (real devices) is timing out whereas Android is working fine. The same error is replicated whether I initiate the tests locally or through Github actions.

I made no code changes nor updates. Not sure why the code stopped working. I have been browsing for any known issues, but couldn’t find any.

Here’s a snippet of the driver factory code,

case "sauce_iOS":
			
			capabilities = new MutableCapabilities();
			capabilities.setCapability("appium:automationName", "XCUITEST");
			capabilities.setCapability("platformName", "iOS");
			capabilities.setCapability("appium:platformVersion", "17");
			capabilities.setCapability("appium:deviceName", "iPhone 14 Plus");
			//capabilities.setCapability("appium:udid", AppConstants.IOS.SAUCE_IOS_REAL_DEVICE_UDID);
			capabilities.setCapability("appium:deviceOrientation", "PORTRAIT");
			capabilities.setCapability("appium:fullReset", true);
			capabilities.setCapability("appium:waitForIdleTimeout", 300);
			capabilities.setCapability("appium:wdaLaunchTimeout", 50000);
			capabilities.setCapability("appium:shouldUseSingletonTestManager", false);
			capabilities.setCapability("appium:showXcodeLog", true);
			capabilities.setCapability("appium:showIOSLog", true);
//			capabilities.setCapability("appium:systemPort", 8209);
			capabilities.setCapability("appium:commandTimeouts", 120000);
			capabilities.setCapability("appium:newCommandTimeout", 90);
			if (AppConstants.MOBILEEXECUTIONTYPE.equalsIgnoreCase("App")) {
				capabilities.setCapability("appium:useNativeCachingStrategy", false);
				if(AppConstants.IOS.SAUCE_IOS_APP.equalsIgnoreCase("latest")) {
					capabilities.setCapability("appium:app", "storage:filename=**-beta.ipa");
				} else {
					capabilities.setCapability("appium:app", AppConstants.IOS.SAUCE_IOS_APP);
				}
				capabilities.setCapability("appium:includeSafariInWebviews", true);
				capabilities.setCapability("appium:webviewConnectTimeout", 30000);
				capabilities.setCapability("appium:fullContextList", true);
				capabilities.setCapability("appium:webkitResponseTimeout", 60000);
			} else {
				capabilities.setCapability("browserName", "safari");
				switch (AppConstants.IOS.SAUCE_IOS_BROWSERNAME.toLowerCase()) {
				case "safari":
					WebDriverManager.safaridriver().clearResolutionCache().setup();
					break;

				default:
					System.out.println("Incorrect web browser for iOS");
				}
			}

			sauceOptions = new HashMap<String, Object>();
			sauceOptions.put("appiumVersion","latest");
			sauceOptions.put("username", AppConstants.SauceLabs.SAUCE_USERNAME);
			sauceOptions.put("accessKey", AppConstants.SauceLabs.SAUCE_ACCESS_KEY);
			sauceOptions.put("build", "appium-build-***");
			capabilities.setCapability("sauce:options", sauceOptions);

			try {
				driver = new IOSDriver(new URI("https://ondemand.us-west-1.saucelabs.com:443/wd/hub").toURL(), capabilities);
			
				
			} catch (Exception e) {
				System.out.println("*** Problem to create the IOS driver " + e.getMessage());
				throw e;
			}
			
			break;

Following is the error,

Jun 13, 2024 12:16:10 PM org.openqa.selenium.remote.ErrorCodes toStatus
INFO: HTTP Status: '408' -> incorrect JSON status mapping for 'timeout' (500 expected)
  Then user sees Digital Ordering Sales metric on Metrics Summary Page # stepdefinitions.CFANowMetricsTestSteps.scrollToDigitalOrderingSalesMetricTest()
      org.openqa.selenium.TimeoutException: Appium did not get any response from 'findElement' command in 90000 ms
Build info: version: '4.16.1', revision: '9b4c83354e'
System info: os.name: 'Mac OS X', os.arch: 'aarch64', os.version: '14.5', java.version: '22.0.1'
Driver info: io.appium.java_client.ios.IOSDriver
Command: [c8cd5f9a-7cdc-4811-8c0d-16609457a72b, findElement {using=xpath, value=//XCUIElementTypeWindow[1]//XCUIElementTypeScrollView//XCUIElementTypeStaticText[last()-1]}]
Capabilities {appium:additionalWebviewBundleIds: [M89Z3BYKYV.M89Z3BYKYV*], appium:appiumData: {appiumVersion: latest, automationName: XCUITEST}, appium:automationName: XCUITEST, appium:bundleId: com.cfahome.atcfanow.test, appium:commandTimeouts: {default: 90000}, appium:databaseEnabled: false, appium:deviceContextId: 2b659077-c425-4af2-9b09-e34..., appium:deviceName: 00008110-00092CAA1E09401E, appium:deviceOrientation: PORTRAIT, appium:fullContextList: true, appium:includeSafariInWebviews: true, appium:javascriptEnabled: true, appium:jobUuid: 80eac71a7cfd4d66a05044d014a..., appium:language: en, appium:locale: en_GB, appium:locationContextEnabled: false, appium:networkConnectionEnabled: false, appium:newCommandTimeout: 90, appium:noReset: true, appium:orientation: PORTRAIT, appium:platformVersion: 17.3, appium:processArguments: {args: [], env: {}}, appium:shouldUseSingletonTestManager: false, appium:showIOSLog: true, appium:showXcodeLog: true, appium:takesScreenshot: true, appium:testobject_device: iPhone_14_Plus_17_real_sjc1_1, appium:testobject_device_name: iPhone 14 Plus, appium:testobject_device_session_id: a323e87c-55d1-4f84-b3b2-1d5..., appium:testobject_test_report_api_url: https://api.us-west-1.sauce..., appium:testobject_test_report_url: https://app.saucelabs.com/t..., appium:testobject_user_id: chickfila_admin, appium:udid: 00008110-00092CAA1E09401E, appium:useNativeCachingStrategy: false, appium:usedCachedDevice: false, appium:waitForIdleTimeout: 300, appium:wdaLaunchTimeout: 50000, appium:webDriverAgentUrl: http://127.0.0.1:5721, appium:webStorageEnabled: false, appium:webkitResponseTimeout: 60000, appium:webviewConnectTimeout: 30000, platformName: IOS, sauce:options: {accessKey: 8606cbaf-4bdb-4510-ad80-dde..., appLaunchStateTimeoutSec: 50, appiumVersion: latest, build: appium-build-6YOQR, realDevice: true, username: sso-chick-fil-a-nitya.jakkam1}}
Session ID: c8cd5f9a-7cdc-4811-8c0d-16609457a72b
	at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486)
	at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:200)
	at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:133)
	at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:52)
	at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:191)
	at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:238)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:523)
	at org.openqa.selenium.remote.ElementLocation$ElementFinder$2.findElement(ElementLocation.java:165)
	at org.openqa.selenium.remote.ElementLocation.findElement(ElementLocation.java:59)
	at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:360)
	at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:354)
	at org.cfa.cfanow.pages.BasePage.scrollToElement(BasePage.java:442)
	at org.cfa.cfanow.pages.BasePage.scrollToElement(BasePage.java:427)
	at org.cfa.cfanow.pages.MetricsPage.scrollToDigitalOrderingSalesCell(MetricsPage.java:957)
	at stepdefinitions.CFANowMetricsTestSteps.scrollToDigitalOrderingSalesMetricTest(CFANowMetricsTestSteps.java:443)
	at ✽.user sees Digital Ordering Sales metric on Metrics Summary Page(file:///Users/nityajaakkam/eclipse-workspace/cfaNow-AppiumTests/src/test/resources/Features/Metrics.feature:1376)

  And verify Digital Ordering Sales metric tile elements               # stepdefinitions.CFANowMetricsTestSteps.verifyDigitalOrderingSalesMetricTile()
      org.openqa.selenium.NoSuchSessionException: A session is either terminated or not started
Build info: version: '4.16.1', revision: '9b4c83354e'
System info: os.name: 'Mac OS X', os.arch: 'aarch64', os.version: '14.5', java.version: '22.0.1'
Driver info: io.appium.java_client.ios.IOSDriver
Command: [c8cd5f9a-7cdc-4811-8c0d-16609457a72b, screenshot {}]
Capabilities {appium:additionalWebviewBundleIds: [M89Z3BYKYV.M89Z3BYKYV*], appium:appiumData: {appiumVersion: latest, automationName: XCUITEST}, appium:automationName: XCUITEST, appium:bundleId: com.cfahome.atcfanow.test, appium:commandTimeouts: {default: 90000}, appium:databaseEnabled: false, appium:deviceContextId: 2b659077-c425-4af2-9b09-e34..., appium:deviceName: 00008110-00092CAA1E09401E, appium:deviceOrientation: PORTRAIT, appium:fullContextList: true, appium:includeSafariInWebviews: true, appium:javascriptEnabled: true, appium:jobUuid: 80eac71a7cfd4d66a05044d014a..., appium:language: en, appium:locale: en_GB, appium:locationContextEnabled: false, appium:networkConnectionEnabled: false, appium:newCommandTimeout: 90, appium:noReset: true, appium:orientation: PORTRAIT, appium:platformVersion: 17.3, appium:processArguments: {args: [], env: {}}, appium:shouldUseSingletonTestManager: false, appium:showIOSLog: true, appium:showXcodeLog: true, appium:takesScreenshot: true, appium:testobject_device: iPhone_14_Plus_17_real_sjc1_1, appium:testobject_device_name: iPhone 14 Plus, appium:testobject_device_session_id: a323e87c-55d1-4f84-b3b2-1d5..., appium:testobject_test_report_api_url: https://api.us-west-1.sauce..., appium:testobject_test_report_url: https://app.saucelabs.com/t..., appium:testobject_user_id: chickfila_admin, appium:udid: 00008110-00092CAA1E09401E, appium:useNativeCachingStrategy: false, appium:usedCachedDevice: false, appium:waitForIdleTimeout: 300, appium:wdaLaunchTimeout: 50000, appium:webDriverAgentUrl: http://127.0.0.1:5721, appium:webStorageEnabled: false, appium:webkitResponseTimeout: 60000, appium:webviewConnectTimeout: 30000, platformName: IOS, sauce:options: {accessKey: 8606cbaf-4bdb-4510-ad80-dde..., appLaunchStateTimeoutSec: 50, appiumVersion: latest, build: appium-build-6YOQR, realDevice: true, username: sso-chick-fil-a-nitya.jakkam1}}
Session ID: c8cd5f9a-7cdc-4811-8c0d-16609457a72b
	at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486)
	at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:200)
	at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:133)
	at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:52)
	at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:191)
	at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:238)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:523)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:596)
	at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:307)
	at org.openqa.selenium.remote.RemoteWebDriver.getScreenshotAs(RemoteWebDriver.java:326)
	at io.appium.java_client.AppiumDriver.getScreenshotAs(AppiumDriver.java:316)
	at stepdefinitions.CommonSteps.takeScreenshotOnFailure(CommonSteps.java:119)

      org.openqa.selenium.NoSuchSessionException: A session is either terminated or not started
Build info: version: '4.16.1', revision: '9b4c83354e'
System info: os.name: 'Mac OS X', os.arch: 'aarch64', os.version: '14.5', java.version: '22.0.1'
Driver info: io.appium.java_client.ios.IOSDriver
Command: [c8cd5f9a-7cdc-4811-8c0d-16609457a72b, quit {}]
Capabilities {appium:additionalWebviewBundleIds: [M89Z3BYKYV.M89Z3BYKYV*], appium:appiumData: {appiumVersion: latest, automationName: XCUITEST}, appium:automationName: XCUITEST, appium:bundleId: com.cfahome.atcfanow.test, appium:commandTimeouts: {default: 90000}, appium:databaseEnabled: false, appium:deviceContextId: 2b659077-c425-4af2-9b09-e34..., appium:deviceName: 00008110-00092CAA1E09401E, appium:deviceOrientation: PORTRAIT, appium:fullContextList: true, appium:includeSafariInWebviews: true, appium:javascriptEnabled: true, appium:jobUuid: 80eac71a7cfd4d66a05044d014a..., appium:language: en, appium:locale: en_GB, appium:locationContextEnabled: false, appium:networkConnectionEnabled: false, appium:newCommandTimeout: 90, appium:noReset: true, appium:orientation: PORTRAIT, appium:platformVersion: 17.3, appium:processArguments: {args: [], env: {}}, appium:shouldUseSingletonTestManager: false, appium:showIOSLog: true, appium:showXcodeLog: true, appium:takesScreenshot: true, appium:testobject_device: iPhone_14_Plus_17_real_sjc1_1, appium:testobject_device_name: iPhone 14 Plus, appium:testobject_device_session_id: a323e87c-55d1-4f84-b3b2-1d5..., appium:testobject_test_report_api_url: https://api.us-west-1.sauce..., appium:testobject_test_report_url: https://app.saucelabs.com/t..., appium:testobject_user_id: chickfila_admin, appium:udid: 00008110-00092CAA1E09401E, appium:useNativeCachingStrategy: false, appium:usedCachedDevice: false, appium:waitForIdleTimeout: 300, appium:wdaLaunchTimeout: 50000, appium:webDriverAgentUrl: http://127.0.0.1:5721, appium:webStorageEnabled: false, appium:webkitResponseTimeout: 60000, appium:webviewConnectTimeout: 30000, platformName: IOS, sauce:options: {accessKey: 8606cbaf-4bdb-4510-ad80-dde..., appLaunchStateTimeoutSec: 50, appiumVersion: latest, build: appium-build-6YOQR, realDevice: true, username: sso-chick-fil-a-nitya.jakkam1}}
Session ID: c8cd5f9a-7cdc-4811-8c0d-16609457a72b
	at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486)
	at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:200)
	at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:133)
	at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:52)
	at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:191)
	at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:238)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:523)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:596)
	at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:307)
	at org.openqa.selenium.remote.RemoteWebDriver.quit(RemoteWebDriver.java:438)
	at stepdefinitions.CommonSteps.afterScenario(CommonSteps.java:106)

In addition to the automation test failing, I notice that the Appium Inspector session with Sauce Labs iOS is timing out within 2 minutes. This was not the case before.

Not sure why this issue is only on iOS and suddenly showing up despite no code change.

Only notable changes were:

  1. Appium version update - [[email protected]] but when downgraded to [email protected], still facing the issue
  2. Enabled Zscaler on our systems that initially caused SSL errors which were rectified by the team
1 Like

It’s probably an issue with the app/xctest itself. Outlook is very slow - #2 by mykola-mokhnach looks similar to your issue.

I also started facing this issue some time ago. It used to work as expected but now it started failing in random places. I wrote to support and they suggested to use the latest appium version but it did not help. Also they suggested to send them page source when it fails, but I even can not do this because session is interrupted.

E.g. I put breakpoint on the login screen of our app
Then I too page source the first time and it worked as expected

The second attempt gave the error: TimeoutError: Appium did not get any response from ‘getPageSource’ command in 60000 ms

The third attempt gave error: A session is either terminated or not started

So something happens with appium session… could you pls fix it? It did not work like this before

2 Likes

After looking at the Sauce Lab logs, looks like diffferent commands timeout randomly like findElement, getScreenshot, getPageSource, etc

Following is an example command log of a timed out automation run -

{
    "httpMethod": "POST",
    "httpPathInfo": "/element",
    "requestBody": "{\n  \"using\": \"xpath\",\n  \"value\": \"\\u002f\\u002fXCUIElementTypeStaticText[@name=\\\"Digital Ordering Sales\\\"]\\u002ffollowing-sibling::XCUIElementTypeStaticText[2]\"\n}",
    "responseBody": "{\"value\":{\"element-6066-11e4-a52e-4f735466cecf\":\"5F010000-0000-0000-AB01-000000000000\",\"ELEMENT\":\"5F010000-0000-0000-AB01-000000000000\"}}",
    "timestamp": 1718378017128,
    "duration": 785,
    "responseStatus": 200,
    "statusCode": 0
  },
  {
    "httpMethod": "POST",
    "httpPathInfo": "/element",
    "requestBody": "{\n  \"using\": \"xpath\",\n  \"value\": \"\\u002f\\u002fXCUIElementTypeStaticText[@name=\\\"Digital Ordering Sales\\\"]\\u002ffollowing-sibling::XCUIElementTypeStaticText[3]\"\n}",
    "responseBody": "{\"value\":{\"error\":\"timeout\",\"message\":\"Appium did not get any response from 'findElement' command in 90000 ms\",\"stacktrace\":\"TimeoutError: Appium did not get any response from 'findElement' command in 90000 ms\\n    at XCUITestDriver.proxyCommand (/root/appium/appium2-20240101-2024.01.01/node_modules/appium-xcuitest-driver/lib/commands/proxy-helper.js:122:42)\\n    at /root/appium/appium2-20240101-2024.01.01/node_modules/appium-xcuitest-driver/lib/commands/find.js:123:13\\n    at wrappedCondFn (/root/appium/appium2-20240101-2024.01.01/node_modules/@appium/base-driver [truncated]",
    "timestamp": 1718378018006,
    "duration": 90010,
    "responseStatus": 408,
    "statusCode": 1
  },
  {
    "httpMethod": "GET",
    "httpPathInfo": "/screenshot",
    "requestBody": "",
    "responseBody": "{\"value\":{\"error\":\"invalid session id\",\"message\":\"A session is either terminated or not started\",\"stacktrace\":\"NoSuchDriverError: A session is either terminated or not started\\n    at asyncHandler (/root/appium/appium2-20240101-2024.01.01/node_modules/@appium/base-driver/lib/protocol/protocol.js:315:15)\\n    at /root/appium/appium2-20240101-2024.01.01/node_modules/@appium/base-driver/lib/protocol/protocol.js:518:15\\n    at Layer.handle [as handle_request] (/root/appium/appium2-20240101-2024.01.01/node_modules/express/lib/router/layer.js:95:5)\\n    at next (/root/a [truncated]",
    "timestamp": 1718378108220,
    "duration": 4,
    "responseStatus": 404,
    "statusCode": 1,
    "screenshotUrl": "https://api.us-west-1.saucelabs.com/v1/rdc/jobs/f7e4026135f840bfae4f2934a1fea6f4/screenshots/{\"value\":{\"error\":\"invalid session id\",\"message\":\"A session is either terminated or not started\",\"stacktrace\":\"NoSuchDriverError: A session is either terminated or not started\\n    at asyncHandler (/root/appium/appium2-20240101-2024.01.01/node_modules/@appium/base-driver/lib/protocol/protocol.js:315:15)\\n    at /root/appium/appium2-20240101-2024.01.01/node_modules/@appium/base-driver/lib/protocol/protocol.js:518:15\\n    at Layer.handle [as handle_request] (/root/appium/appium2-20240101-2024.01.01/node_modules/express/lib/router/layer.js:95:5)\\n    at next (/root/a [truncated]"
  },
  {
    "httpMethod": "DELETE",
    "httpPathInfo": "",
    "requestBody": "",
    "responseBody": "{\"value\":{\"error\":\"invalid session id\",\"message\":\"A session is either terminated or not started\",\"stacktrace\":\"NoSuchDriverError: A session is either terminated or not started\\n    at asyncHandler (/root/appium/appium2-20240101-2024.01.01/node_modules/@appium/base-driver/lib/protocol/protocol.js:315:15)\\n    at /root/appium/appium2-20240101-2024.01.01/node_modules/@appium/base-driver/lib/protocol/protocol.js:518:15\\n    at Layer.handle [as handle_request] (/root/appium/appium2-20240101-2024.01.01/node_modules/express/lib/router/layer.js:95:5)\\n    at next (/root/a [truncated]",
    "timestamp": 1718378108337,
    "duration": 2,
    "responseStatus": 404,
    "statusCode": 1
  }

Following is the example for Appium Inspector session,

  {
    "httpMethod": "GET",
    "httpPathInfo": "/screenshot",
    "requestBody": "",
    "responseBody": "5",
    "timestamp": 1718376461319,
    "duration": 146,
    "responseStatus": 200,
    "statusCode": 0,
    "screenshotUrl": "https://api.us-west-1.saucelabs.com/v1/rdc/jobs/1fdb62b3e6a9464d9d2389812988e9a8/screenshots/5"
  },
  {
    "httpMethod": "GET",
    "httpPathInfo": "/window/rect",
    "requestBody": "",
    "responseBody": null,
    "timestamp": 1718376461950,
    "duration": null,
    "responseStatus": 0,
    "statusCode": 0
  },
  {
    "httpMethod": "GET",
    "httpPathInfo": "/source",
    "requestBody": "",
    "responseBody": null,
    "timestamp": 1718376462222,
    "duration": null,
    "responseStatus": 0,
    "statusCode": 0
  },
  {
    "httpMethod": "GET",
    "httpPathInfo": "/timeouts",
    "requestBody": "",
    "responseBody": null,
    "timestamp": 1718376463950,
    "duration": null,
    "responseStatus": 0,
    "statusCode": 0
  },
  {
    "httpMethod": "GET",
    "httpPathInfo": "/timeouts",
    "requestBody": "",
    "responseBody": null,
    "timestamp": 1718376504044,
    "duration": null,
    "responseStatus": 0,
    "statusCode": 0
  },
{
    "httpMethod": "GET",
    "httpPathInfo": "/screenshot",
    "requestBody": "",
    "responseBody": "{\"value\":{\"error\":\"timeout\",\"message\":\"Appium did not get any response from 'getPageSource' command in 60000 ms\",\"stacktrace\":\"TimeoutError: Appium did not get any response from 'getPageSource' command in 60000 ms\\n    at XCUITestDriver.proxyCommand (/root/appium/2.0.1-updated-timeouts-2023.08.15.14.09.57/node_modules/appium-xcuitest-driver/lib/commands/proxy-helper.js:125:42)\\n    at XCUITestDriver.getNativePageSource (/root/appium/2.0.1-updated-timeouts-2023.08.15.14.09.57/node_modules/appium-xcuitest-driver/lib/commands/source.js:32:7)\\n    at XCUITestDriver.ge [truncated]",
    "timestamp": 1718376514496,
    "duration": 7739,
    "responseStatus": 408,
    "statusCode": 1,
    "screenshotUrl": "https://api.us-west-1.saucelabs.com/v1/rdc/jobs/1fdb62b3e6a9464d9d2389812988e9a8/screenshots/{\"value\":{\"error\":\"timeout\",\"message\":\"Appium did not get any response from 'getPageSource' command in 60000 ms\",\"stacktrace\":\"TimeoutError: Appium did not get any response from 'getPageSource' command in 60000 ms\\n    at XCUITestDriver.proxyCommand (/root/appium/2.0.1-updated-timeouts-2023.08.15.14.09.57/node_modules/appium-xcuitest-driver/lib/commands/proxy-helper.js:125:42)\\n    at XCUITestDriver.getNativePageSource (/root/appium/2.0.1-updated-timeouts-2023.08.15.14.09.57/node_modules/appium-xcuitest-driver/lib/commands/source.js:32:7)\\n    at XCUITestDriver.ge [truncated]"
  },
  {
    "httpMethod": "GET",
    "httpPathInfo": "/source",
    "requestBody": "",
    "responseBody": "{\"value\":{\"error\":\"invalid session id\",\"message\":\"A session is either terminated or not started\",\"stacktrace\":\"NoSuchDriverError: A session is either terminated or not started\\n    at asyncHandler (/root/appium/2.0.1-updated-timeouts-2023.08.15.14.09.57/node_modules/@appium/base-driver/lib/protocol/protocol.js:315:15)\\n    at /root/appium/2.0.1-updated-timeouts-2023.08.15.14.09.57/node_modules/@appium/base-driver/lib/protocol/protocol.js:518:15\\n    at Layer.handle [as handle_request] (/root/appium/2.0.1-updated-timeouts-2023.08.15.14.09.57/node_modules/express/li [truncated]",
    "timestamp": 1718376522415,
    "duration": 5,
    "responseStatus": 404,
    "statusCode": 1
  },
  {
    "httpMethod": "GET",
    "httpPathInfo": "/timeouts",
    "requestBody": "",
    "responseBody": "{\"value\":{\"error\":\"invalid session id\",\"message\":\"A session is either terminated or not started\",\"stacktrace\":\"NoSuchDriverError: A session is either terminated or not started\\n    at asyncHandler (/root/appium/2.0.1-updated-timeouts-2023.08.15.14.09.57/node_modules/@appium/base-driver/lib/protocol/protocol.js:315:15)\\n    at /root/appium/2.0.1-updated-timeouts-2023.08.15.14.09.57/node_modules/@appium/base-driver/lib/protocol/protocol.js:518:15\\n    at Layer.handle [as handle_request] (/root/appium/2.0.1-updated-timeouts-2023.08.15.14.09.57/node_modules/express/li [truncated]",
    "timestamp": 1718376523940,
    "duration": 2,
    "responseStatus": 404,
    "statusCode": 1
  },
  {
    "httpMethod": "GET",
    "httpPathInfo": "/timeouts",
    "requestBody": "",
    "responseBody": "{\"value\":{\"error\":\"invalid session id\",\"message\":\"A session is either terminated or not started\",\"stacktrace\":\"NoSuchDriverError: A session is either terminated or not started\\n    at asyncHandler (/root/appium/2.0.1-updated-timeouts-2023.08.15.14.09.57/node_modules/@appium/base-driver/lib/protocol/protocol.js:315:15)\\n    at /root/appium/2.0.1-updated-timeouts-2023.08.15.14.09.57/node_modules/@appium/base-driver/lib/protocol/protocol.js:518:15\\n    at Layer.handle [as handle_request] (/root/appium/2.0.1-updated-timeouts-2023.08.15.14.09.57/node_modules/express/li [truncated]",
    "timestamp": 1718376543961,
    "duration": 4,
    "responseStatus": 404,
    "statusCode": 1
  },
  {
    "httpMethod": "GET",
    "httpPathInfo": "/screenshot",
    "requestBody": "",
    "responseBody": "{\"value\":{\"error\":\"invalid session id\",\"message\":\"A session is either terminated or not started\",\"stacktrace\":\"NoSuchDriverError: A session is either terminated or not started\\n    at asyncHandler (/root/appium/2.0.1-updated-timeouts-2023.08.15.14.09.57/node_modules/@appium/base-driver/lib/protocol/protocol.js:315:15)\\n    at /root/appium/2.0.1-updated-timeouts-2023.08.15.14.09.57/node_modules/@appium/base-driver/lib/protocol/protocol.js:518:15\\n    at Layer.handle [as handle_request] (/root/appium/2.0.1-updated-timeouts-2023.08.15.14.09.57/node_modules/express/li [truncated]",
    "timestamp": 1718376545193,
    "duration": 3,
    "responseStatus": 404,
    "statusCode": 1,
    "screenshotUrl": "https://api.us-west-1.saucelabs.com/v1/rdc/jobs/1fdb62b3e6a9464d9d2389812988e9a8/screenshots/{\"value\":{\"error\":\"invalid session id\",\"message\":\"A session is either terminated or not started\",\"stacktrace\":\"NoSuchDriverError: A session is either terminated or not started\\n    at asyncHandler (/root/appium/2.0.1-updated-timeouts-2023.08.15.14.09.57/node_modules/@appium/base-driver/lib/protocol/protocol.js:315:15)\\n    at /root/appium/2.0.1-updated-timeouts-2023.08.15.14.09.57/node_modules/@appium/base-driver/lib/protocol/protocol.js:518:15\\n    at Layer.handle [as handle_request] (/root/appium/2.0.1-updated-timeouts-2023.08.15.14.09.57/node_modules/express/li [truncated]"
  },
  {
    "httpMethod": "GET",
    "httpPathInfo": "/window/rect",
    "requestBody": "",
    "responseBody": "{\"value\":{\"error\":\"invalid session id\",\"message\":\"A session is either terminated or not started\",\"stacktrace\":\"NoSuchDriverError: A session is either terminated or not started\\n    at asyncHandler (/root/appium/2.0.1-updated-timeouts-2023.08.15.14.09.57/node_modules/@appium/base-driver/lib/protocol/protocol.js:315:15)\\n    at /root/appium/2.0.1-updated-timeouts-2023.08.15.14.09.57/node_modules/@appium/base-driver/lib/protocol/protocol.js:518:15\\n    at Layer.handle [as handle_request] (/root/appium/2.0.1-updated-timeouts-2023.08.15.14.09.57/node_modules/express/li [truncated]",
    "timestamp": 1718376545315,
    "duration": 4,
    "responseStatus": 404,
    "statusCode": 1
  },
  {
    "httpMethod": "GET",
    "httpPathInfo": "/contexts",
    "requestBody": "",
    "responseBody": "{\"value\":{\"error\":\"invalid session id\",\"message\":\"A session is either terminated or not started\",\"stacktrace\":\"NoSuchDriverError: A session is either terminated or not started\\n    at asyncHandler (/root/appium/2.0.1-updated-timeouts-2023.08.15.14.09.57/node_modules/@appium/base-driver/lib/protocol/protocol.js:315:15)\\n    at /root/appium/2.0.1-updated-timeouts-2023.08.15.14.09.57/node_modules/@appium/base-driver/lib/protocol/protocol.js:518:15\\n    at Layer.handle [as handle_request] (/root/appium/2.0.1-updated-timeouts-2023.08.15.14.09.57/node_modules/express/li [truncated]",
    "timestamp": 1718376545443,
    "duration": 2,
    "responseStatus": 404,
    "statusCode": 1
  },
  {
    "httpMethod": "GET",
    "httpPathInfo": "/source",
    "requestBody": "",
    "responseBody": "{\"value\":{\"error\":\"invalid session id\",\"message\":\"A session is either terminated or not started\",\"stacktrace\":\"NoSuchDriverError: A session is either terminated or not started\\n    at asyncHandler (/root/appium/2.0.1-updated-timeouts-2023.08.15.14.09.57/node_modules/@appium/base-driver/lib/protocol/protocol.js:315:15)\\n    at /root/appium/2.0.1-updated-timeouts-2023.08.15.14.09.57/node_modules/@appium/base-driver/lib/protocol/protocol.js:518:15\\n    at Layer.handle [as handle_request] (/root/appium/2.0.1-updated-timeouts-2023.08.15.14.09.57/node_modules/express/li [truncated]",
    "timestamp": 1718376545599,
    "duration": 3,
    "responseStatus": 404,
    "statusCode": 1
  },
  {
    "httpMethod": "POST",
    "httpPathInfo": "/actions",
    "requestBody": "{\"actions\":[{\"type\":\"pointer\",\"id\":\"finger1\",\"parameters\":{\"pointerType\":\"touch\"},\"actions\":[{\"type\":\"pointerMove\",\"duration\":0,\"x\":24,\"y\":86},{\"type\":\"pointerDown\",\"button\":0},{\"type\":\"pause\",\"duration\":100},{\"type\":\"pointerUp\",\"button\":0}]}]}",
    "responseBody": "{\"value\":{\"error\":\"invalid session id\",\"message\":\"A session is either terminated or not started\",\"stacktrace\":\"NoSuchDriverError: A session is either terminated or not started\\n    at asyncHandler (/root/appium/2.0.1-updated-timeouts-2023.08.15.14.09.57/node_modules/@appium/base-driver/lib/protocol/protocol.js:315:15)\\n    at /root/appium/2.0.1-updated-timeouts-2023.08.15.14.09.57/node_modules/@appium/base-driver/lib/protocol/protocol.js:518:15\\n    at Layer.handle [as handle_request] (/root/appium/2.0.1-updated-timeouts-2023.08.15.14.09.57/node_modules/express/li [truncated]",
    "timestamp": 1718376552040,
    "duration": 2,
    "responseStatus": 404,
    "statusCode": 1
  },
  {
    "httpMethod": "DELETE",
    "httpPathInfo": "",
    "requestBody": "",
    "responseBody": "{\"value\":{\"error\":\"invalid session id\",\"message\":\"A session is either terminated or not started\",\"stacktrace\":\"NoSuchDriverError: A session is either terminated or not started\\n    at asyncHandler (/root/appium/2.0.1-updated-timeouts-2023.08.15.14.09.57/node_modules/@appium/base-driver/lib/protocol/protocol.js:315:15)\\n    at /root/appium/2.0.1-updated-timeouts-2023.08.15.14.09.57/node_modules/@appium/base-driver/lib/protocol/protocol.js:518:15\\n    at Layer.handle [as handle_request] (/root/appium/2.0.1-updated-timeouts-2023.08.15.14.09.57/node_modules/express/li [truncated]",
    "timestamp": 1718376555542,
    "duration": 3,
    "responseStatus": 404,
    "statusCode": 1
  }

I have been able to have Appium Inspector sessions for like 10 minutes before with no issues.

Similarly with automation, since last week, I used to get the timeout issue rarely but not consistently for every single run.

I am also observing similar issue consistently while running the test in iOS - Saucelab devices. While noticing the saucelabs logs, new command is not passed for certain time even after adding commandTimeouts / commandTimeouts (90 sec) capabilities.

Is the issue reproducible if the same test is being executed with a locally deployed Appium server instance on a local device?

Apologies for the late response. I don’t have any real device to run locally & for some reason, Appium tests are not running on iphone simulator despite updating to the latest Xcode 15.4. However, I was able to run tests locally a few back as well.

this issue is also faced with our team, this week random failures with ios 17 only on saucelabs with respect to findElements timing out in 60000 ms we have tried different approaches with retry logics and used the provided online solutions to increase timeouts but still facing this issue.

1 Like

mykola-mokhnach First of all, thank you for your response.
Latest Update:
I was able to get ios emulator working and my automation is working completely fine there.

System info: os.name: ‘Mac OS X’, os.arch: ‘aarch64’, os.version: ‘14.5’, java.version: ‘22.0.1’

But I am still facing the timeout issue on Sauce Labs. So could be a Sauce Labs issue? or an XCUITEST issue?

Any tips/advice on debugging further to help narrow the issue further?

1 Like

Final Update:

I am not sure what changed since the last 2 weeks and this week but the timeout issue is no longer happening.

Turns out it was Sauce Labs issue for iOS 17 devices using Xpath locators. They fixed them last week & hence resolved the issue.

1 Like

Hello,

I encountered the same issue on Sauce Labs with iOS. The Appium session quit unexpectedly with the message (truncated):

“TimeoutError: Appium did not get any response from ‘[…]’ command in […] ms
at XCUITestDriver.proxyCommand […]”

I found out that the crash of the XCUITestDriver occurred when within an Appium session i had 3 Apps running at the same time (including foreground and background processes): the app under test and two additional apps.
And I found out that I can prevent the crash when having at most one additional app running.
I activate and terminate the additional apps via Appium’s “executeScript” API, using “mobile:activateApp” and “mobile:terminateApp”.

My test procedure includes the following apps:

  • app under test (app No. 1)
  • mobile Safari app (app No. 2)
  • mobile Files app (app No. 3)

So, the crash occurs in particular with this test procedure:

  • activate app No. 1, interact with the app
  • activate app No. 2, interact with the app
  • activate app No. 3, interact with the app → after some interaction: crash

For my particular test case, I am able to use an alternative procedure which does not require both, the apps No. 2 and 3 to be running at the same time.
So, the crash does not occur with this test procedure:

  • activate app No. 1, interact with the app
  • activate app No. 2, interact with the app
  • after having finished all interactions with app No. 2: terminate app No. 2
  • activate app No. 3, interact with the app → no crash

@FrankThonig I have a test where I first open the app, then I click a button in the app and it takes me to settings of the application, where I need to do something in order to activate the debug menu in the app. However, sometimes it freezes in the settings screen, although it opens the correct screen, and this happens on both simulator and on Saucelabs intermittently. Any ideas how to avoid this, since I don’t use three apps like you described?