Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to send some arguments through the instruments command-line where UI Automation script could access them?

I'm trying to send some arguments to UI Automation scripts through the command-line where the scripts could grab those arguments and execute some specific test cases conditionally based on those received arguments. Is there a way to do this? I saw in the manual page for the instruments command that it mentioned something about arguments.

argument ~ Command line argument to be sent to the launched process (You may specify more than one)

https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/instruments.1.html

... Or should I just split the conditional code into different files and have some external shell scripts to handle changing of the file name to be executed through the instruments command-line instead?

like image 550
Krissada Dechokul Avatar asked Feb 15 '23 01:02

Krissada Dechokul


1 Answers

My workaround on this problem uses an exported environment variable and the UIATarget.localTarget().host().performTaskWithPathArgumentsTimeout(...) command to acquire that parameter.

  1. Export an environment variable in the shell

    export PARAM_TO_UIA="theParameterValue"

  2. Launch instruments from the same shell

  3. Acquire the parameter inside your UIAutomation script

    var result = target.host().performTaskWithPathArgumentsTimeout("/usr/bin/printenv" , ["PARAM_TO_UIA"], 5);

    var parameter = result.stdout.substring(0,result.stdout.length-1);

Last command removes '\n' from the end of the result.stdout string.

like image 53
fabe Avatar answered Apr 08 '23 22:04

fabe