我有一个像这样的脚本:
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();
我想要做的是读取文本文件或数据库连接,因此我可以用文本文件中的值或数据库查询替换“ Hello World”。在Instruments应用程序中使用JavaScript来控制iphone模拟器的UI自动化,这是否可能?
对的,这是可能的。您可以在bash脚本中获取所有能够获取的数据。编写一个脚本文件,将所需的信息打印到标准输出。例如
#!/bin/bash
cat myfile
您可以从UIAutomation运行此bash脚本,并使用以下命令获取其输出
var result = target.host().performTaskWithPathArgumentsTimeout(full_path_to_your_script, [""], 10);
现在,您可以使用bash脚本的输出了:
element.setValue(result.stdout);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句