2013-05-14 60 views
3

我想在iPhone上用于连接到任何给定的Wi-Fi网络的UI自动化。我想自动设置应用程序。它应该自动:自动化的设置应用程序,iPhone

  1. 打开设置应用程序;
  2. 打开Wi-Fi;
  3. 通过提供SSIDWPA连接到给定的网络。

我的问题是:

  1. 是否有可能使用自动化UI自动化任何内置的应用程序? Apple/iOS安全模型是否排除了对内置应用程序的访问?
  2. 如果有可能,该如何实现?

回答

2

是的,这是可能的,容易做到的。选择“Preferences.app”(设置)作为您的目标,然后为其余的脚本编写脚本。该 “Preferences.app” 位于您的Xcode应用程序内

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs//Applications/Preferences.app

+0

如果我没看错,这是不再可能是什么呢? – Braains 2014-07-22 20:35:44

+0

我也有兴趣找出如何做到这一点?必须有一些方法来自动化物理iPhone上的设置应用程序? – bearaman 2015-04-22 09:38:32

+0

@Ricardo B.我喜欢你,因为这有助于我的回答! – Jules 2015-04-28 18:24:53

4

我知道我迟到了,但我想提供一个更完整的答案并详细阐述我的解决方案。

我从shell脚本运行我uiautomation,这里是我的解决方案..

(你必须删除空格等)

settingsapp.sh

#!/bin/bash 
sleep 5s 
instruments -v -w MY_SIMULATOR_DEVICE_ID -t 
/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/ 
PlugIns/AutomationInstrument.xrplugin/Contents/Resources/ 
Automation.tracetemplate /Applications/Xcode.app/Contents/Developer/ 
Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/ 
Applications/Preferences.app -e UIASCRIPT 
/Users/ path to my js file/settingapp.js 

settingapp.js

var target = UIATarget.localTarget(); 
target.delay(1.0); 
target.frontMostApp().mainWindow().tableViews()[0].cells() 
    ["General"].tap(); 

target.delay(1.0); 
target.frontMostApp().mainWindow().tableViews()[0].cells() 
    ["Language & Region"].tap(); 

target.delay(1.0); 
target.frontMostApp().mainWindow().tableViews()[0].cells() 
    ["Region"].tap(); 

target.delay(1.0); 
target.frontMostApp().mainWindow().tableViews()[0].cells() 
    ["United Kingdom"].tap(); 

target.delay(1.0); 

所以,你可以有几个shell脚本,首先一个设置langua GE,然后又做截屏,然后再次运行切换到另一种语言等。

:)

+1

请注意,这不适用于实际的设备... – Cristik 2016-02-25 11:40:17