Unable to run WebDriverAgent on the real device using Appium Desktop - ios

I am unable to run WebDriverAgent on a real device using Appium Desktop. I have attached gist for the error log.
I have tried some solution from github/appium but it did not solve my issue.
server log
https://gist.github.com/guowang94/ec923da6a3b77aca06a902c450200238
appium.app error message
https://gist.github.com/guowang94/ef2c5bb5bcc617baa2af19418e9a8b8e
I expect the WebDriverAgent to be running in the real device so that I can proceed to my next task but I am unable to install and run WebDriverAgent on the real device

Your logs have both the problem:
An empty identity is not valid when signing a binary for the product type 'UI Testing Bundle'. (in target 'WebDriverAgentRunner')
which indicates incorrect XCode configuration with regards to signing the WebDriverAgentRunner-Runner.app
and the solution:
Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65 .... Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md
If the official guide is not clear you can follow steps from the Configuring Appium Environment for iOS Real Device article.
You can also consider Appium Studio which makes the process of setting up Appium testing on real iOS devices much easier.

Related

How to solve 'Test runner exited before starting test execution' error for iPhone Devices

Context -
We have E2E Testing running on the CI on the iPhone devices.
The script performs the following steps -
Build the Test runner app from code.
Extracts the app file from the IPA.
Re-codesign the app with the required Provision Profiles.
Creates a .xctestrun file
Uses the xcodebuild command like the following to run the test -
xcodebuild -sdk iphoneos -destination id=<device_id> -xctestrun <path_to_xctestrun_file> -resultBundlePath <path_to_test_bundle_file> test-without-building -only-testing:E2ETestsBundle.xctest/<test_filter>
The above command installs the runner and target app into the device and starts executing the test.
The apps get installed and uninstalled at each run during a single execution.
Problem -
During the execution, the xcodebuild CLI tool, suddenly loses connection to the device and is not able to install the apps into the device and then results in the following error -
Testing failed:
E2ETestsBundle.xctest:
E2ETestsBundle-Runner encountered an error (Early unexpected exit, operation never finished bootstrapping - no restart will be attempted. (Underlying Error: Test runner exited before starting test execution. If you believe this error represents a bug, please attach the log file at /var/folders/1r/0xlnbmzd0yj3m_cc7p95yb4r0000gn/T/tmpl7d9p1s6/testResults.bundle/Staging/1_Test/Diagnostics/E2ETestsBundle-Configuration-Test Scheme Action-Iteration-1/E2ETestsBundle/Session-E2ETestsBundle-2022-04-13_205520-muaMCx.log))
** TEST EXECUTE FAILED **
Points to note -
The xcodebuild CLI tool will keep on failing with the error once it occurred until recovered.
Even while the xcodebuild is in a failed state, the devices are still accessible via Xcode IDE and other CLI tools like libimobiledevice and are able to install both the test runner and target applications.
This is occurring intermittently across all devices models and across subversions of iOS 14 and 15.
Recovery -
The only way to recover is to reboot the device.
Even after a reboot, the devices start facing this exception again after a few days of execution.
As we can’t keep on rebooting the device every time before execution, we need a solution to fix this problem.
Any help would be appreciated!!

webdriveragentrunner iphoneos12.2-arm64.xctestrun doesn't exist

I want to automate ios app using appium.
The thing is that I am getting this error when I use appium inspector in order to open my installed application for the first time:
xcodebuild failure: "xcodebuild failed with code 65"
I followed different solutions I found online (like enable automatically manage signings in webdriveragent project, code signing identity...) but I am still getting this error.
Seems that this path does't exist in my computer.
Is there a way to fix this issue?
Thanks
You need to walk through Appium XCUITest Driver Real Device Setup article and perhaps Real device security settings chapter of the appium-xcuitest-driver documentation.
Most probably you have wrong XCode configuration with regards to signing mobile application packages
The easiest option would be considering using Appium Studio which has a simple wizard allowing creation of iOS provisioning profile in few clicks.
In my case I had to use one command from Full manual configuration
Steps that I made:
install appium:
npm install -g appium
Successfully build webDriverAgentRunner from xcode.
cd /usr/local/lib/node_modules/appium/node_modules/appium-webdriveragent
xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<id_of_your_device>' test
Don't kill the console
Open appium desktop and try to connect

is 'APP' capability REQUIRED for WDA installation?

I'm trying to run an appium script with a real iOS device. I am currently getting this error:
Encountered internal error running command: Error: Unable to launch WebDriverAgent because of xcodebuild failure: "xcodebuild failed with code 65". 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.
Apparently this error is associated with security issues at noted here, but I've already completed that step and it's still not working. So then I thought maybe this is b/c my appium script does NOT set the 'APP' capability. 'APP' capability is of course is the full path to the application that is under test. The appium documentation here obviously doesn't indicate which settings are required if any. My question is will the Webdriver Agent not get installed on the device if the 'APP' capability is not set and thus throwing the error above?
You can right-click on the appium app (which is in ur application folder) you are using > show package contents > search for .xcodeproj > you will see a couple of projects including web driver. Now open web driver agent Xcode project and use an apple developer account to code sign it.
If you have already done this, then please update your question with appium capabilities that you have set.

Unable to launch app on IOS Simulator - WebDriver Agent error

I have installed Appium and XCode and am trying to launch an app on the simulator. The app works when I open the simulator manually and click on the app.
My capabilities look as follows:
File app = new File ("/Users/me/Desktop/myapp.app");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("platformName", "iOS");
capabilities.setCapability("deviceName", "iPhone 8");
capabilities.setCapability("automationName", "XCUITest");
capabilities.setCapability("app", app.getAbsolutePath());
driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
The error I get is:
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Unable to launch WebDriverAgent because of xcodebuild failure: "Command 'Scripts/bootstrap.sh -d' exited with code 1". (WARNING: The server did not provide any stacktrace information)
I followed the instructions given in the answer to this question:
Unable to launch ipa file in IOS 10 real Device using appium 1.6.0
When I build the WebDriverAgent through XCode, it builds without any problems, but as soon as I try to launch through IntelliJ or Appium Desktop, it gives me that error.
So I eventually managed to get it working, here are some of the errors that I encountered and how I fixed them:
Unable to launch WebDriverAgent because of xcodebuild failure: "Command 'Scripts/bootstrap.sh -d' exited with code 1
Solution: looking at the Appium server log, I noticed that it was unable to write to a directory. The problem was that my Appium app was sitting in Downloads. Once I moved it to Applications, this problem was fixed.
XCode build failed with exit code 65
Solution: the problem here was with my Provisioning Profiles (I opened the app in XCode and went to the General tab to see these).
I had created a personal apple account, but I didn't have the certificates needed to run the app. I had to get one of our iOS developers to invite me to their team, downloaded certificates and then ticked the "Automatically manage signing" check box -- there were a couple of other steps with the certificates that I can't remember.
It was connecting to the simulator, it launched WebDriverManager, but then wouldn't launch my app (it just hung).
Solution: I had made a mistake in my capabilities, I had it set as:
capabilities.setCapability("bundleId", "com.facebook.WebDriverAgentLib");
Which was the bundleID for WebDriverAgent, I updated it with the bundleID for my app:
capabilities.setCapability("bundleId", "myapp");
(Bundle ID can be found by going to the app in finder, right clicking and selecting "Show Package Contents". Open the "Info.plist" file and there you'll find the Bundle ID for the app.

Calabash-ios: Run test physical device installed ipa without xcodeproj

I am new with calabash-ios and have a dummy question is:
How possibly could I run a calabash test with real device which have installed ipa file (included calabash framework) and without xcodeproj?
Problem is I am doing QA and Dev only gives me ipa file to test without source code.
UPDATE:
I am able to run the ipa file in console and cucumber by adding BUNDLE_ID. And make sure the CFNetwork.framework is including in app framework to establish the connection.
But I got another problem to run the scenario:
1. When I run the command below:
DEVICE_ENDPOINT=http://192.168.1.9:37265 NO_LAUNCH=1 BUNDLE_ID=com.example.appname DEVICE_TARGET=UDID cucumber
Then I got this error:
A JSON text must at least contain two octets! (JSON::ParserError)
features/my_first.feature:8:in `Then I touch "LOG-IN/ CREATE ACCOUNT"'
all other steps was skipped
Then I run the console code
DEVICE_ENDPOINT=http://192.168.1.9:37265 NO_LAUNCH=1 BUNDLE_ID=com.example.appname DEVICE_TARGET=UDID calabash-ios console
Then I run server_version
I got reply back that said connection SUCCEED
But when I run start_test_server_in_background
It took me too long to wait and I see the app my physical device kept crashed and launch again and again until it stop as:
Unable to start. Make sure you've set APP_BUNDLE_PATH to a build supported by this simulator version
Calabash::Cucumber::Launcher::StartError: Calabash::Cucumber::Launcher::StartError:
"Timed out waiting for UIAutomation run-loop Error while writing to fifo. RunLoop::Fifo::NoReaderConfiguredError.
2015-10-01 10:49:41.634 instruments[15640:10558880] WebKit Threading Violation - initial use of WebKit from a secondary thread.
2015-10-01 10:49:42.574 instruments[15640:10558978] Attempting to change event horizon while disengage
2015-10-01 10:49:42.577 instruments[15640:10558877] Attempting to change event horizon while disengage
Instruments Trace Error : Target failed to run: Permission to debug app
Anyone can help please! I tried to search some solution but they almost issue on simulator and they contain xcodeproj. As a QA, I dont have the source code, only .ipa file. :(
Thanks
You should set 3 variables:
$ DEVICE_TARGET=<UDID> \
DEVICE_ENDPOINT=http://<ip>:37265 \
BUNDLE_ID=com.example.YourApp cucumber
The device and the host computer should be on the same network.
The .ipa must be installed on your device.
You can do this in Xcode by dragging-and-dropping in the Device Manager window or with a third-party tool like ideviceinstaller (available with homebrew).
You should never set NO_LAUNCH.
http://calabashapi.xamarin.com/ios/file.ENVIRONMENT_VARIABLES.html#label-NO_LAUNCH
You also need to enable you device for develop and turn on UIAutomation in the Settings.app > Developer.
Enabling device for development
RunLoop::Fifo::NoReaderConfiguredError
UPDATE In response to this question, I rewrote the Testing on Physical Devices Calabash iOS wiki page. Wow, that content was ancient!
As long as the file is build with calabash then that is not a problem. You just call cucumber with APP_BUNDLE_PATH to where ever your .ipa file is and should be all set.
But you should be aware that .ipa needs to be build to match the target you run the tests on.

Resources