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

前端 未结 1 1181
刺人心
刺人心 2021-01-14 03:33

I have a script like so:

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

var element = mainWindow.textFields()[\"         


        
1条回答
  •  说谎
    说谎 (楼主)
    2021-01-14 04:32

    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);
    

    0 讨论(0)
提交回复
热议问题