Appium: WebDriverAgent is uninstalled from iPad and never installed again

WebDriverAgent is uninstalled from iPad and never installed again throwing xcode error:
“org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: An unknown server-side error occurred while processing the command. Original error: Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65”

Configuration:

Appium : 1.22.0/1.22.2/1.22.0/1.22.0-beta

Mac OS: macOS Monterey v12.1

Xcode: 13.0

java-client - 8.0.0-beta

Selenium - 4.1.0

Followed below tutorials:

https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md

Error Logs:

org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: An unknown server-side error occurred while processing the command. Original error: Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65
xcodebuild error message:

2022-01-21 11:49:21.109 xcodebuild[96868:1671553] [MT] IDETestOperationsObserverDebug: (2B376EA3-D48B-44EE-8EE5-A14AAC6B3949) Failed to make test runner session:
Error Domain=com.apple.dt.xctest.error Code=9 “Unable to connect to test manager on dfb994683be4aa90965d0836323ad4e7c0d04514” UserInfo={NSLocalizedDescription=Unable to connect to test manager on dfb994683be4aa90965d0836323ad4e7c0d04514, NSUnderlyingError=0x6000029748a0 {Error Domain=XCTMobileDeviceFramework Code=34 “The service is invalid.” UserInfo={NSLocalizedDescription=The service is invalid.}}}
2022-01-21 11:49:21.340 xcodebuild[96868:1671553] [MT] DTDKRemoteDeviceConnection: Failed to start Instruments daemon on device “dfb994683be4aa90965d0836323ad4e7c0d04514”: Error Domain=com.apple.dtdevicekit Code=811 “Failed to start remote service on device.” UserInfo={NSUnderlyingError=0x60000285cbd0 {Error Domain=com.apple.dt.MobileDeviceErrorDomain Code=-402653150 “The service is invalid.” UserInfo={MobileDeviceErrorCode=(0xE8000022), com.apple.dtdevicekit.stacktrace=(
0 DTDeviceKitBase 0x00000001149e781a DTDKCreateNSErrorFromAMDErrorCode + 233
1 DTDeviceKitBase 0x00000001149f9161 __63-[DTDKRemoteDeviceConnection startFirstServiceOf:unlockKeybag:]_block_invoke + 564
2 DTDeviceKitBase 0x00000001149f8829 __48-[DTDKRemoteDeviceConnection futureWithSession:]_block_invoke_3 + 22
3 DTDeviceKitBase 0x00000001149e9df9 __DTDKExecuteInSession_block_invoke_2 + 35
4 DTDeviceKitBase 0x00000001149e9209 __DTDKExecuteWithConnection_block_invoke_2 + 473
5 DTDeviceKitBase 0x00000001149e9007 __DTDKExecuteWithConnection_block_invoke + 106
6 libdispatch.dylib 0x00007ff806108cc9 _dispatch_client_callout + 8
7 libdispatch.dylib 0x00007ff8061164a1 _dispatch_sync_invoke_and_complete_recurse + 65
8 libdispatch.dylib 0x00007ff806115ffd _dispatch_sync_f_slow + 194
9 DVTFoundation 0x0000000110bdd368 DVTDispatchBarrierSync + 208
10 DVTFoundation 0x0000000110bb3cc3 -[DVTDispatchLock performLockedBlock:] + 64
11 DTDeviceKitBase 0x00000001149e8f08 DTDKExecuteWithConnection + 226
12 DTDeviceKitBase 0x00000001149e9c63 DTDKExecuteInSession + 376
13 DTDeviceKitBase 0x00000001149f866a __48-[DTDKRemoteDeviceConnection futureWithSession:]_block_invoke_2 + 131
14 DVTFoundation 0x0000000110bda7f4 DVT_CALLING_CLIENT_BLOCK + 7
15 DVTFoundation 0x0000000110bdc436 __DVTDispatchAsync_block_invoke + 1194
16 libdispatch.dylib 0x00007ff806107ad8 _dispatch_call_block_and_release + 12
17 libdispatch.dylib 0x00007ff806108cc9 _dispatch_client_callout + 8
18 libdispatch.dylib 0x00007ff80610ecee _dispatch_lane_serial_drain + 696
19 libdispatch.dylib 0x00007ff80610f7fb _dispatch_lane_invoke + 417
20 libdispatch.dylib 0x00007ff8061197e1 _dispatch_workloop_worker_thread + 758
21 libsystem_pthread.dylib 0x00007ff8062bc074 _pthread_wqthread + 326
22 libsystem_pthread.dylib 0x00007ff8062baffb start_wqthread + 15
), DVTRadarComponentKey=261622, NSLocalizedDescription=The service is invalid.}}, NSLocalizedRecoverySuggestion=Please check your connection to your device., DVTRadarComponentKey=261622, NSLocalizedDescription=Failed to start remote service on device.}
*** If you believe this error represents a bug, please attach the result bundle at /Users/rishi/Library/Developer/Xcode/DerivedData/WebDriverAgent-ciegwgvxzxdrqthilmrmczmqvrgu/Logs/Test/Test-WebDriverAgentRunner-2022.01.21_11-49-21-+0530.xcresult
2022-01-21 11:49:21.342 xcodebuild[96868:1671553] [MT] IDETestOperationsObserverDebug: 0.294 elapsed – Testing started completed.
2022-01-21 11:49:21.342 xcodebuild[96868:1671553] [MT] IDETestOperationsObserverDebug: 0.000 sec, +0.000 sec – start
2022-01-21 11:49:21.342 xcodebuild[96868:1671553] [MT] IDETestOperationsObserverDebug: 0.294 sec, +0.294 sec – end
Test session results, code coverage, and logs:
/Users/rishi/Library/Developer/Xcode/DerivedData/WebDriverAgent-ciegwgvxzxdrqthilmrmczmqvrgu/Logs/Test/Test-WebDriverAgentRunner-2022.01.21_11-49-21-+0530.xcresult
Testing failed:
WebDriverAgentRunner:
WebDriverAgentRunner-Runner.app encountered an error (Failed to establish communication with the test runner. (Underlying error: Unable to connect to test manager on dfb994683be4aa90965d0836323ad4e7c0d04514. (Underlying error: The service is invalid.)))
** TEST EXECUTE FAILED **
Testing started on ‘Rishi Khanna’s iPad’. Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. Try to remove the WebDriverAgentRunner application from the device if it is installed and reboot the device.
Build info: version: ‘4.1.0’, revision: ‘87802e897b’
System info: host: ‘192.168.1.3’, ip: ‘fe80:0:0:0:10e1:8403:814d:ca22%en0’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.16’, java.version: ‘1.8.0_221’
Driver info: io.appium.java_client.ios.IOSDriver
Command: [null, newSession {capabilities=[{appium:autoAcceptAlerts=true, appium:bundleId=com.salido.ios.v2.staging.PointOfSale, appium:deviceName=iPad Pro (12.9-inch, 2nd generation) (Model A1670), appium:newCommandTimeout=500, appium:noReset=true, platformName=iOS, appium:platformVersion=15.0, appium:toggleSoftwareKeyboard=true, appium:udid=dfb994683be4aa90965d0836323ad4e7c0d04514, appium:useNewWDA=true, appium:usePrebuiltWDA=true, appium:wdaLocalPort=37001, appium:xcodeOrgId=7365A2X7SU, appium:xcodeSigningId=iPhone Developer}], desiredCapabilities=Capabilities {autoAcceptAlerts: true, bundleId: com.xxx, deviceName: iPad Pro (12.9-inch, 2nd ge…, newCommandTimeout: 500, noReset: true, platformName: iOS, platformVersion: 15.0, toggleSoftwareKeyboard: true, udid: xxx…, useNewWDA: true, usePrebuiltWDA: true, wdaLocalPort: 37001, xcodeOrgId:, xcodeSigningId: iPhone Developer}}]
Capabilities {}

did you pre-build WDA manually?

Yes I did build it manually

if you build manually you do not need →

oiiiiiiiii I am wrong!
adding mine just to compare →

{
app: /Users/qa/Documents/test/ap...,
automationName: XCuiTest,
bundleId: com.xxx,
clearSystemFiles: true,
derivedDataPath: /Users/qa/Library/Developer...,
deviceName: iPhone QA8,
forceAppLaunch: true,
fullReset: false,
iosInstallPause: 500,
launchWithIDB: true, // a bit faster load app to phone
newCommandTimeout: 180,
noReset: false,
platformName: iOS,
platformVersion: 15.2,
shouldTerminateApp: true,
shouldUseSingletonTestManager: false,
showXcodeLog: false,
udid: xxx,
useJSONSource: true,
useNewWDA: true,
usePrebuiltWDA: true,
waitForAppScript: 10001,
waitForIdleTimeout: 0,
waitForQuiescence: false,
wdaLaunchTimeout: 120000,
wdaLocalPort: 6108,
wdaStartupRetries: 4,
xcodeOrgId: xxx,
xcodeSigningId: iPhone Developer
}

Also your xcode version looks a bit old try update it.

No luck. Tried removing xcodeSigningId, iPhone Developer and useNewWDA capability and running the code. wda is still removed from ipad and never gets re-installed during execution

  1. update xcode tried?
  2. maybe someone disabled automation on iPad in settings :slight_smile: ?

Tried with 13.2 version.
UI Automation is turned ON.
Actually it was working for me until I upgraded to new java client and selenium library.
My other Mac has older versions of all software and dependencies and everything works smoothly.

@Aleksei any other area you can think of that needed more attention to solve this issue? Or if you can route this to someone who can help me here?

Out of ideas. Maybe check how you build WDA. I use option Any iOS Device.

@Aleksei Created generic wda as well. But when I tried to install it it shows “info.plist” error.

ERROR: could not locate /Users/xxx/Library/Developer/Xcode/DerivedData/WebDriverAgent-ciegwgvxzxdrqthilmrmczmqvrgu/Build/Products/Debug-iphoneos/WebDriverAgentRunner-Runner.app/Info.plist in app!

Tried installing to ipad using ideviceinstaller on terminal

@Aleksei When I manually build wda directly onto my ipad, it installs successfully but when any script is executed it will delete the installed wda and do not re-install it back.

Below is the error logs:

org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: An unknown server-side error occurred while processing the command. Original error: Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 70
xcodebuild error message:

Command line invocation:

/Users/govind/Downloads/Xcode.app/Contents/Developer/usr/bin/xcodebuild test-without-building -project /usr/local/lib/node_modules/appium/node_modules/appium-webdriveragent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination id=dfb994683be4aa90965d0836323ad4e7c0d04514 IPHONEOS_DEPLOYMENT_TARGET=15.0 -xcconfig /var/folders/p5/k1j6lgnd30dg6ggnrrvlmqv00000gn/T/202217-14986-10p0rqh.xse4/appium-temp.xcconfig GCC_TREAT_WARNINGS_AS_ERRORS=0 COMPILER_INDEX_STORE_ENABLE=NO
Build settings from command line:
COMPILER_INDEX_STORE_ENABLE = NO
GCC_TREAT_WARNINGS_AS_ERRORS = 0
IPHONEOS_DEPLOYMENT_TARGET = 15.0
Build settings from configuration file ‘/var/folders/p5/k1j6lgnd30dg6ggnrrvlmqv00000gn/T/202217-14986-10p0rqh.xse4/appium-temp.xcconfig’:
CODE_SIGN_IDENTITY = iPhone Developer
DEVELOPMENT_TEAM = 7365A2X7SU
2022-02-07 13:32:40.399 xcodebuild[15004:3965865] [MT] iPhoneConnect: :iphone:<DVTiOSDevice (0x7fae59b1d110), iPad Pro (12.9-inch) (2nd generation), iPad, 15.0 (19A346), dfb994683be4aa90965d0836323ad4e7c0d04514> == Underlying device preparation errors ==
2022-02-07 13:32:40.400 xcodebuild[15004:3965865] [MT] iPhoneConnect: Failed _shouldMakeReadyForDevelopment check even though device is not locked by passcode.
Domain: com.apple.platform.iphoneos
Code: 5
Failure Reason: allowsSecureServices: 1. isConnected: 0. Platform: <DVTPlatform:0x6000012c4800:‘com.apple.platform.iphoneos’:DVTFilePath:0x6000012c4780:’/Users/govind/Downloads/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform’>. DTDKDeviceIdentifierIsIDID: 0
User Info: {
DVTDeviceDescription = “\Ud83d\Udcf1<DVTiOSDevice (0x7fae59b1d110), Rishi Khanna\U2019s iPad, iPad, 15.0 (19A346), dfb994683be4aa90965d0836323ad4e7c0d04514>”;
}

2022-02-07 13:32:40.400 xcodebuild[15004:3965865] [MT] iPhoneConnect: :iphone:<DVTiOSDevice (0x7fae59b1d110), iPad Pro (12.9-inch) (2nd generation), iPad, 15.0 (sdv), dfb994683be4aa90965d0836323ad4e7xxxxxxx> == END: Underlying device preparation errors ==
xcodebuild: error: Unable to find a destination matching the provided destination specifier:
{ id:dfb994683be4aa90965d0836323ad4e7c0xxxxxxx }
Available destinations for the “WebDriverAgentRunner” scheme:
{ platform:macOS, arch:x86_64, variant:Mac Catalyst, id:55DA-98BC-E8735C95ADAB }
Ineligible destinations for the “WebDriverAgentRunner” scheme:
{ platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Generic iOS Device }
{ platform:iOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-iphonesimulator:placeholder, name:Generic iOS Simulator Device }. Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. Try to remove the WebDriverAgentRunner application from the device if it is installed and reboot the device.
Build info: version: ‘4.1.0’, revision: ‘87802e897b’
System info: host: ‘192.168.1.9’, ip: ‘fe80:0:0:0:10e1:8403:814d:ca22%en0’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.16’, java.version: ‘1.8.0_221’
Driver info: io.appium.java_client.ios.IOSDriver
Command: [null, newSession {capabilities=[{appium:autoAcceptAlerts=true, appium:bundleId=xxxxx, appium:deviceName=iPad Pro (12.9-inch, 2nd generation) (Model A1670), appium:newCommandTimeout=500, appium:noReset=true, platformName=iOS, appium:platformVersion=15.0, appium:showXcodeLog=true, appium:toggleSoftwareKeyboard=true, appium:udid=dfb994683be4aa90965d0836323ad4e7c0d04514, appium:usePrebuiltWDA=true, appium:wdaLocalPort=16141, appium:xcodeOrgId=7365A2X7SU, appium:xcodeSigningId=iPhone Developer}], desiredCapabilities=Capabilities {autoAcceptAlerts: true, bundleId: com.salido.ios.v2.staging.P…, deviceName: iPad Pro (12.9-inch, 2nd ge…, newCommandTimeout: 500, noReset: true, platformName: iOS, platformVersion: 15.0, showXcodeLog: true, toggleSoftwareKeyboard: true, udid: dfb994683be4aa90965…, usePrebuiltWDA: true, wdaLocalPort: 16141, xcodeOrgId: 7365A2X7SU, xcodeSigningId: iPhone Developer}}]
Capabilities {}

i see this error in logs.

Updating to xcode 13.2.1 resolved all underlying issues