Open MagdelineNg opened 4 months ago
I realised that the Identifier attribute used in Xpath for the element has changed when I print the page source of the app in the Jenkins VM environment. Is the XC Identifier attribute not unique and changes across different machines?
I tested xpath with a title attribute for the element which does not change across environments, but am still the driver is not able to find the element even though the xpath of the element is valid and found in driver.page_source
I can see this printed in the logs on the VM:
-------------------------------- live log call --------------------------------- WARNING urllib3.connectionpool:connectionpool.py:874 Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fc6d1521160>: Failed to establish a new connection: [Errno 61] Connection refused')': /session/1f324abc509025d06118a66eeded1c6f WARNING urllib3.connectionpool:connectionpool.py:874 Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fc6d1521490>: Failed to establish a new connection: [Errno 61] Connection refused')': /session/1f324abc509025d06118a66eeded1c6f WARNING urllib3.connectionpool:connectionpool.py:874 Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fc6d1521e80>: Failed to establish a new connection: [Errno 61] Connection refused')': /session/1f324abc509025d06118a66eeded1c6f
Hi, after more debugging by remote desktop into the Jenkins VM, I realised the Appium logs is getting stuck at this line:
[WebDriverAgentMac] [xcodebuild] t = 414.4s Find the Application 'com.company.TestApp
I logged errors from my python script, and received this:
Stacktrace:
UnknownError: An unknown server-side error occurred while processing the command. Original error: Failed to determine bundle identifier for '/Volumes/jenkins/workspace/CPIDSDK-4800/builds/scripts/ui_automation_test_pkgs/IDSDK/1.11.10.111/ubx64arm64/Release/TestHarness/TestApp.app'. The application may be damaged or incomplete.
at errorFromW3CJsonCode (/usr/local/lib/node_modules/appium/node_modules/@appium/base-driver/lib/protocol/errors.js:1085:25)
at ProxyRequestError.getActualError (/usr/local/lib/node_modules/appium/node_modules/@appium/base-driver/lib/protocol/errors.js:954:14)
at WDAMacProxy.command (/usr/local/lib/node_modules/appium/node_modules/@appium/base-driver/lib/jsonwp-proxy/proxy.js:353:19)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at Mac2Driver.macosActivateApp (/Users/IDSDK/.appium/node_modules/appium-mac2-driver/lib/commands/app-management.js:49:10)
at Mac2Driver.executeMacosCommand (/Users/IDSDK/.appium/node_modules/appium-mac2-driver/lib/commands/execute.js:54:10)
at Mac2Driver.execute (/Users/IDSDK/.appium/node_modules/appium-mac2-driver/lib/commands/execute.js:44:12)
Any idea why the application is identified as damaged or incomplete, even though Mac2 driver is able to launch it?
Maybe the system log has more info. The error might came from the XCTest framework's activate
API call
https://github.com/appium/appium-mac2-driver/blob/master/lib/commands/app-management.js#L49
https://github.com/appium/appium-mac2-driver/blob/e935c90e1e8918295cd3afbeb01e24e756e2fe38/WebDriverAgentMac/WebDriverAgentLib/Routing/FBSession.m#L112
https://developer.apple.com/documentation/xctest/xcuiapplication/2873317-activate
Is there a reason why the Mac2 driver may throw
NoSuchElementError: unable to find an element using 'xpath', value '//XCUIElementTypeButton[@elementType="9" and @identifier="_NS:291"]'
in the CI environment (specifically, running on an ECS VM with GUI in Jenkins), but the driver able to locate the element using the same XPath when I run the script locally on my Mac?The Jenkins node is able to locate certain Xpaths but not others as seen in logs where some status codes are 200 while others are 404. This is the environment I am running Mac2 driver on:
Here are the Appium logs on the VM: