iOS-从Apple Store注销/以编程方式还原设备 [英] iOS - Logout from Apple Store / Restore Device Programmatically

查看:198
本文介绍了iOS-从Apple Store注销/以编程方式还原设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在自动化测试用例以在多个设备中并行运行.我为此使用Appium,效果很好.我的问题是我有一些测试用例,需要将设备登录到特定的Apple Store帐户.另外,该设备可能已经登录到另一个帐户,并且我没有手动注销的选项.我的测试用例在设备未连接任何帐户的情况下可以很好地登录帐户(在我的应用程序中,我尝试执行需要Apple ID的操作,出现需要登录的警报,并且我已经使登录过程自动化).问题是该设备已经登录到另一个帐户.

I'm automating test cases to run in several devices in parallel. I'm using Appium for this and this works fine. My issue is that I have some test cases that need the device to be logged into specific Apple Store accounts. Also, it is possible that the device might already be logged into another account and I don't have the option to logout manually. My test cases to log into an account if the device has no account attached to it already run well (inside my app I try to do an action that requires an Apple ID, the alert requiring login appears and I already automated the login process). The issue is when the device is already logged into another account.

我的两个选择是:

  • 强制设备从Apple Store注销
  • 在不进行记录的情况下创建设备备份,并在测试前恢复该备份

我无法找到处理第一个选项的方法.第二个使用idevicebackup2(libimobiledevice的一个库)工作.这里的问题是,还原设备数据后,将出现安装向导,并且无法自动删除它.我尝试使用cfgutils删除向导步骤,但是即使删除了所有步骤,该向导也会出现,只是在还原后等待确认.

I wasn't able to find a way to handle the first option. The second one works using idevicebackup2 (a lib from libimobiledevice). The issue here is that after restoring the device data, the setup wizard appear and there is no way to get rid of it automatically. I tried using cfgutils to remove the wizard steps, but even after removing all steps, the wizard appears just waiting for a confirmation after restoring.

我想知道第一种选择是否可行,第二种选择是否跳过设置向导,或者部分恢复备份(仅清除Apple ID数据)为了避免重新启动设备并再次卡住向导.预先感谢.

I would like to know if there is a way to go for the first option, or a way to skip the setup wizard in the second option, or maybe a way to restore the backup partially (just clearing the Apple ID data) in order to avoid rebooting the device and getting stuck with the wizard again. Thanks in advance.

推荐答案

Xcode 9现在可用的一个选项是新的多应用程序测试.现在,您可以在XCUI测试期间根据其捆绑包标识符XCUIApplication(bundleIdentifier: "com.MEGACORP.xyz")调用系统上的任何应用程序.它们在WWDC会话409中介绍了新的API和示例-测试中的新功能-值得一看.

One option available now with Xcode 9 is the new multi-app testing. You can now call any app on the system based on it's bundle identifier XCUIApplication(bundleIdentifier: "com.MEGACORP.xyz") during a XCUI test. They cover the new API and examples in WWDC session 409 - What's New in Testing - it's worth watching the whole thing.

我已经使用新的API编写了一些测试,以退出测试中的应用程序,并打开系统设置以在测试崩溃期间重置应用程序状态.在问题.

I've written some tests using the new API to switch out of the app under test and open System Settings to reset the app state during the test teardown. There's a list of all the system bundle ids in this question.

您的测试将以类似以下内容的方式开始:

Your test would start with something like:

let store = XCUIApplication(bundleIdentifier: "com.apple.AppStore")
store.launch()

这篇关于iOS-从Apple Store注销/以编程方式还原设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆