问题描述
我正在尝试使用Apple的UIAutomation为具有服务器端组件的iOS应用程序编写单元测试。为了在各种状态下设置测试服务器(以及模拟通过我的服务器进行通信的两个客户端),我想在基于javascript的测试中发出HTTP get请求。
I am trying to use Apple's UIAutomation to write unit tests for an iOS Application that has a server-side component. In order to setup the test server in various states (as well as simulate two clients communicating through my server), I would like to issue HTTP get requests from within my javascript-based test.
任何人都可以提供一个示例,说明如何直接从UIAutomation javascript测试中发出HTTP GET请求,或者如何从我的UIAutomation javascript测试中调用shell脚本?
Can anyone provide an example of how to either issue HTTP GET requests directly from within UIAutomation javascript tests, or how to invoke a shell script from within my UIAutomation javascript tests?
FWIW,UIAutomation运行时中缺少所有浏览器可用的大多数核心对象。例如,尝试使用XMLHTTPRequest,您将收到一个异常报告,它无法找到该变量。
FWIW, most of the core objects made available by all browsers are missing within the UIAutomation runtime. Try to use XMLHTTPRequest for example and you will get an exception reporting that it cannot find the variable.
谢谢!
推荐答案
尝试
UIATarget.host().performTaskWithPathArgumentsTimeout("/usr/bin/curl", "http://google.com", 30);
这篇关于从iOS UIAutomation发出JavaScript中的同步HTTP GET请求或调用shell脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!