从数据库或文本文件中读取数据在仪器javascript脚本中 [英] read data from a database or text file in instruments javascript script

查看:198
本文介绍了从数据库或文本文件中读取数据在仪器javascript脚本中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的脚本:

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

我想要做的是读取一个文本文件或数据库连接,世界与来自文本文件或数据库查询的值。这是可能在Instruments应用程序中使用javascript来控制UI模拟器的UI自动化?

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?

推荐答案

您可以获取您能够在bash脚本中获取的每个数据。
编写一个脚本文件,将所需的信息打印到标准输出。例如

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

您可以从UIAutomation运行此bash脚本,并使用此命令获取输出。

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

现在您可以使用bash脚本的输出:

Now your can use the output of your bash script:

element.setValue(result.stdout);

这篇关于从数据库或文本文件中读取数据在仪器javascript脚本中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆