设置应用程序自动化,iPhone

3
我正在尝试在iPhone上进行UI自动化以连接任何给定的Wi-Fi网络。我想自动化设置应用程序。它应该自动执行以下操作:
  1. 打开设置应用程序;
  2. 打开Wi-Fi;
  3. 通过提供SSID和WPA连接到给定网络。
我的问题是:
  1. 是否可以使用UI自动化自动化任何内置应用程序? Apple / iOS安全模型是否排除了对内置应用程序的任何此类访问?
  2. 如果可能,如何实现?
2个回答

4

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

我从shell脚本运行我的UI自动化,这是我的解决方案...

(您需要删除空格等)

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脚本,首先一个用于设置语言,然后另一个用于进行屏幕截图,然后运行另一个切换到另一种语言等等。

:)


2
是的,这是可能且容易实现的。选择“Preferences.app”(设置)作为您的目标,并编写其余部分的脚本。 “Preferences.app”位于您的Xcode应用程序内部。
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs//Applications/Preferences.app

我也很想知道如何做到这一点?肯定有一些方法可以自动化物理iPhone上的设置应用程序吧? - bearaman
@Ricardo B. 我给你点赞,因为这对我的回答有所帮助! - Jules

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接