从UIAutomation调用webservice

时间:2013-11-07 12:52:37

标签: ios iphone web-services ui-automation ios-ui-automation

是否可以从UIAutomation调用网络服务?

在此网页上http://www.geonames.org/export/ajax-postalcode-autocomplete.html 可以输入国家和邮政编码,并获得以下回复

http://api.geonames.org/postalCodeLookupJSON?postalcode=2830&country=DK&username=demo

 {"postalcodes":[{"postalcode":"2830","countryCode":"DK","lng":12.4666667,"placeName":"Virum","lat":55.8}]}

我对此很新,有没有办法可以用参数调用服务或自己构建网址并调用它并以JSON的形式获得UIAutomation的响应?

1 个答案:

答案 0 :(得分:0)

你可以这样做:

var result = target.host().performTaskWithPathArgumentsTimeout("/usr/bin/curl", ["http://yoururl"], 30);
var json = JSON.parse(result.stdout)