How to run instruments with new instances from the command line? - ios

I want to have the ability to run scripts on multiple devices with instruments at the same time.
I found that if I open new instances of instrument (File -> New),
I could run many scripts on different devices at the same time, but I need to run this from the command line.
I have the command:
instruments -t mytemplate myapp.app
and I can add to this:
-i # The index of the instrument to apply.
how can I find the index of instrument?
or how do I tell the command line to run a script on a specific instance of instruments?

Related

How to run multiple execute windows batch in jenkins

I am trying to open appium, avd, and ride to run a test in Jeninks. I have the following in execute windows batch command:
C:
cd C:\Users\Gebruiker
appium
adb start-server
cd C:\Users\Gebruiker\AppData\Local\Android\Sdk\emulator
emulator -avd Pixel_3_API_23
ride.py
D:
cd D:\RIDE - testproject\Avans-One
robot -d Open_settings_connect_wifi AvansOne
It keeps loading after opening Appium, the first step. I have tried seperating the steps but it still doesnt work. It completes the first step and then just keeps loading. How do i fix this?
Most probably, this is happening because the command used to start the app is not returning while the app is running. So you will have to use a command that allows you to run the application in the background.
Check with something like below.
START /B title program
e.g.:
C:
cd C:\Users\Gebruiker
START /B "" appium
You can read more about the background process here

Launch application in gdb with non-path name

I am trying to launch a legacy application in GDB, and it requires that it's argv[0] value not contain anything other than alphanumeric characters.
Whenever I launch the program in GDB it seems that it expands the name to be the full path before running the program, so I get an error like (because it can't deal with the slashes):
"Cannot find /home/user/myapp ..."
Is it possible to run a program in GDB with a relative path, so that it will just see "myapp"?
Gdb normally runs target commands using the shell command line
exec program_pathname program_arguments
But it has a set exec-wrapper command that will change this to
exec exec_wrapper program_pathname program_arguments
The exec_wrapper is often another command, but it can be an option that the exec command accepts.
Many shells (bash, zsh, ksh93) support a -a option to the exec command to set argv[0].
So, if your shell supports exec -a, you can do the following to invoke /home/user/myapp with argv[0]==myapp:
(gdb) set exec-wrapper -a myapp

iOS - UI Automation multiple scripts with reset application

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.

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

Export instruments trace data via command-line for leaks

I am using the following script to run leaks instruments from the command-line.
instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/Resources/templates/Leaks.tracetemplate <app path>
after executing the command, i get instrumentscli0.trace file. How can i get readable data about leaks from that file.
Is there any way to export the results to a text file via any command. In automation template we can specify an output folder using the switch -e UIARESULTSPATH.
you can click "instrument > export data" in the menu to export the recent result to a .csv file. but i don't know how to do it with command line

Resources