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.
Related
I am integrating Microsoft Itunes SDK in my iOS app. The app already include Azure AD for authentication of user. However now I want my app to communicate with Intunes application and fetch its login.
The microsoft documentation has specified proper step however I am stuck with use of IntuneMAMConfigurator tool.
Can anyone tell me how to use this(IntuneMAMConfigurator) tool exactly?
I had issues with executing the file on macOS Catalina, I had to first give the file access to execute with chmod +x IntuneMAMConfigurator and then run it with ./IntuneMAMConfigurator -i <path> -e <path>
I know it's late to answer this question, but I faced the same issue and Microsoft's documentation is no help on this. To help other folks out there here are the steps.
To run IntuneMAMConfigurator, download it from the SDK repo: https://github.com/MicrosoftDocs/IntuneDocs/blob/master/intune/app-sdk-ios.md
Do not try to open it by double click, this won't work.
Open Terminal and type /path/to/IntuneMAMConfigurator -i plistfile -e entitlementfile
/path/to/ : Type in the full path where IntuneMAMConfigurator is present.
plistfile : Copy and paste the plist file path of your project
entitlementfile : Copy and paste the file path of your entitlements file.
In addition to this if you do not want your existing plist file to change you can create a new plist file by following command:
/path/to/IntuneMAMConfigurator -i plistfile -e entitlementfile -o new plistFile
IntuneMAMConfigurator tool:
Usage 1:
IntuneMAMConfigurator -i /path/to/info.plist -e /path/to/entitlements
Usage 2:
IntuneMAMConfigurator -generateOpenInIcons /path/to/app.app
Optional Usage 1:
IntuneMAMConfigurator -i /path/to/info.plist -e /path/to/entitlements -o /path/to/new/info.plist
Optional Usage 2:
IntuneMAMConfigurator -generateOpenInIcons /path/to/app.app -o /path/to/output/directory
In my case this solution works for me.
Ensure the Entitlements plist is specified in the "Custom Entitlements" field of the project's "iOS Bundle Signing" options for all the appropriate Configuration/Platform combinations.
Also check, Wheather your project paths contains any space means in your path folder name having space.
I am looking for solution where I can set my javascripts with order and when each script would start it would be independent on previous scripts. So I can run just one script or group of them and it would be working same.
I find that I can create one script file and use #import keyword, something like this:
#import "AddStaticContentMissingName.js"
#import "AddStaticContent.js"
It's working and both scripts are running but second one starts where first one ends and that is what bothers me. I can set first one to end when the second one needs but I don't like it. I just one to script do what should test and then end. So is it possible to before each test restart application or something like that? I want to have UI testing automate as possible so what or you using? Or are you using another tool then UI Automation?
Bonus question: I was looking for solution how to run this from command line and/or with Xcode Server. I guess Xcode Server is problem but for command line there is a solution. Problem with solution which I found is that I isn't portable right? I don't have any way how can I add some script to my repository and if someone try use it there would be problems with paths. Example of command I found:
instruments \
-w your_ios_udid \
-t "/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate" \
name_of_your_app \
-e UIASCRIPT absolute_path_to_the_test_file
If you want to reset the application between scripts, you need to do it yourself with a combination of app code and UIAutomation code. (Apple will be replacing Instruments with something that works better, but for now this is the only way.)
For example, if your application doesn't use the "shake" gesture for anything, you could use that to trigger a restart within your app (not closing it, just returning it to a known state). Then at the top of every UIAutomation script, you could just call the method for the shake gesture.
In the testing framework we wrote, we set up our own RPC channel to allow us to expose non-UI functionality (like resetting the app) to automation scripts. It really doesn't matter what system you use to make it happen, as long as you can reliably get the app to a known state.
I might be too late for this but it's totally possible to accomplish what you want. Basically, create a bash script (or any other script) and include the commands to run your two automation scripts:
#!/bin/bash
instruments -w <UDID> -t <template> <app> -e UIASCRIPT <script1>
instruments -w <UDID> -t <template> <app> -e UIASCRIPT <script2>
Run that and your app will restart after the first script creating a trace file per run.
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.
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
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?