2013-05-14 30 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