Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

read data from a database or text file in instruments javascript script

I have a script like so:

var target = UIATarget.localTarget();
var mainWindow = target.frontMostApp().mainWindow();

var element = mainWindow.textFields()["UserID"];
element.setValue("Hello World");

UIALogger.logStart("Logging element tree ...");
target.logElementTree();
UIALogger.logPass();

What I want to do is read a text file or database connection, so I can replace the "Hello World" with either a value from a text file or a database query. Is this possible in the Instruments application with using javascript to control UI Automation for the iphone simulator?

like image 904
Nick Turner Avatar asked May 25 '26 00:05

Nick Turner


1 Answers

Yes it is possible. You can acquire every data that you are able to acquire in a bash script. Write a script file that prints the desired information to the standard output. For example

#!/bin/bash
cat myfile

You can run this bash-script from UIAutomation and get the output of it with this command

var result = target.host().performTaskWithPathArgumentsTimeout(full_path_to_your_script, [""], 10);

Now your can use the output of your bash script:

element.setValue(result.stdout);
like image 139
fabe Avatar answered May 27 '26 12:05

fabe