UIAutomation - command line issue - ios

I would like to access the SETTINGS and turn on/off WiFi.
Therefore I am running the following command:
instruments -v -w [my_phpne_ID] -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/Applications/Preferences.app -e UIASCRIPT /Users/test/Documents/xCode/Shell-Script/mytest.js -e UIARESULTSPATH /Users/test/Documents/xCode/Shell-Script
The following issue pops up:
Instruments : Instrument 'Automation - Preferences' rejected command 'Instrument Command (purpose:Trace;
Do I need to initialize the phone and Xcode somehow?
It usually works after I run a dummy App from Xcode on the phone.
But I would like to avoid it and run this command directly without any dummy App.

Related

Can we instruct PAServer to execute custom commands?

When I finished deploying my app (in release), I would like to automatically send it to the app store. For this I need to run this simple command:
./altool — upload-app -f {abs path to your project}.ipa -u {apple id to publish the app} -p {password of apple id}
Is their a way to instruct PAServer (delphi RIO/Sydney) to run this command at the end of the deployment?

ios-webkit-debug-proxy gets disconnected from ipad while running tests

I am trying to run test on physical iPad. I am using appium and webkit-ios-debug-proxy. But ios-webkit-debug-proxy gets disconnected when i try to run tests. It gives an error -
Invalid message _rpc_applicationUpdated: <dict>
<key>WIRApplicationIdentifierKey</key>
<string>PID...</string>
<key>WIRIsApplicationProxyKey</key>
<false/>
<key>WIRApplicationNameKey</key>
...
</dict>
Disconnected
I found some forums, where it was mentioned to run command -
.bin/ios-webkit-debug-proxy-launcher.js -c UDID -d
from the appium folder, but when I run the command, I get an error -
"module.js: ..throw err Error: Cannot find module
'underscore' at Function.Module_resolveFuleName (module.js:336:15) ....
So that solution does not work for me either.
The command above in the question [.bin/ios-webkit-debug-proxy-launcher.js -c UDID -d ], worked for me eventually.
It wasn't initially working as I was downloading ios-webkit-debug-proxy-launcher.js again from github instead of looking for the .js file in current installation, and also, I guess some ports where not freed from the previous ios_webkit_debug_proxy run. Hence it was throwing an error. In most cases the installation on mac, it should be on /use/local/lib/..
Also, to find and kill existing instances, this worked for me -
ps aux | grep portNumber
OR
ps -efl | grep ios_webkit_debug_proxy
and then
kill -9 PID

Send command to launch app in iOS device using command line tool

I have been through stackOverFlow and google search's but didn't find out a proper answer to my query. I want to send a command to launch app in iOS device(connected via USB port) using command line tool (from mac system). Please don't copy paste link's in comment or in your post as I been through a lot of site's. I'm looking forward to a proper way along with understanding if anyone could provide.
I have seen ios-deploy, libimobiledevice and all but explanation is not given on how to install and use, i.e., test it whether it's working or not. If anyone have then please provide the same with bit of explanation.
Thanks in advance.
Try instruments from command line, replace DEVICE_UDID, XCODE_PATH, APP_PATH, APP_NAME, TRACE_DIR and STARTING_POINT with your variables:
instruments -w DEVICE_UDID \
-t /Applications/XCODE_PATH.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate \
APP_PATH/APP_NAME.app \
-e UIASCRIPT STARTING_POINT.js \
-e UIARESULTSPATH TRACE_DIR \
-d TRACE_DIR
What I have in STARTING_POINT.js:
var target = UIATarget.localTarget();
This example simply launches app on device and then app exit. Note that the app needs proper signing.

Running Automation script without running Xcode

I have written a UI automation script in Instruments and Its working perfectly. Now I want to know is there any way that I simply double click on script and Its start working or at least I don't need to run Xcode for running the script.
instruments -w 1.device_id -t /Developer/Platforms/iPhoneOS.platform/Developer/Library/Instruments/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate 2.application -e UIASCRIPT 3.script -e UI-ARESULTSPATH 4.results path
The ones marked with 1. 2. 3. 4. are the variables that you type. Use this code, put in your device id, app, script and result path and run the whole line in Terminal

How to continue testing an iOS app, using UIAutomation instrument, even after the app exits?

I have an app. There is a button in the app, which, if clicked, exits the app. I am testing the app using UIAutomation instruments. I want to test this button. But after the app exits, the instrument stops giving an exception. What I want to do is that after the app exists, I want to reopen the app and continue with the rest of the test. Have anyone else been in the same scenario? If so, can you please share the solution, if you have found any?
This is not possible because Instruments loses the connection with the app process once it quits.
If you are scripting UI Automation from the command line, you can run a second automation script after the first one quits the app that then checks to make sure everything is reset.
instruments \
-D [trace document] \
-t [instruments template] \
/path/to/Bundle.app \
-e UIARESULTSPATH [directory to store test output] \
-e UIASCRIPT reset_the_app.js
instruments \
-D [trace document] \
-t [instruments template] \
/path/to/Bundle.app \
-e UIARESULTSPATH [directory to store test output] \
-e UIASCRIPT check_that_the_app_is_reset.js
So, rather than trying to get the same instance of Instruments to relaunch and reattach to the app, just run two separate scripts, one that does your reset-and-abort, and the other that checks the resulting state of the app.
You can Use:
UIATarget.localTarget().deactivateAppForDuration(n);
where n is the number of seconds you want this app to restart. I hope this helps.
thanks for the answers, but the documentation says:
"When a user exits your app by tapping the Home button or causing some other app to come to the foreground, your app is suspended."
So its not restarting but suspended?

Resources