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

查看:31
本文介绍了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 - 测试中的新功能 - 值得一看.

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天全站免登陆