【问题标题】:Automation of Settings app, iPhone设置应用程序自动化,iPhone
【发布时间】:2013-05-08 14:53:08
【问题描述】:

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

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

我的问题是:

  1. 是否可以使用 UI 自动化自动化任何内置应用程序? Apple/iOS 安全模型是否会阻止对内置应用的任何此类访问?
  2. 如果可能,如何实现?

【问题讨论】:

    标签: ios automation ui-automation ios-ui-automation


    【解决方案1】:

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

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

    :)

    【讨论】:

      【解决方案2】:

      是的,这是可能的,而且很容易做到。选择“Preferences.app”(设置)作为目标并为其余部分编写脚本。 “Preferences.app”位于您的 Xcode 应用程序中

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

      【讨论】:

      • 我也有兴趣了解如何执行此操作?必须有某种方法可以自动化物理 iPhone 上的设置应用程序???
      • @Ricardo B. 我支持你,因为这有助于我的回答!
      猜你喜欢
      • 1970-01-01
      • 2015-11-15
      • 1970-01-01
      • 2014-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-24
      • 1970-01-01
      相关资源
      最近更新 更多