UIAutomation 脚本 ios - deactivateAppForDuration 抛出 nil
UIAutomation script ios - deactivateAppForDuration throwing nil
当我在 ios 9 ipad 视网膜模拟器中 运行 我的自动化脚本 (UIautomation ios) 然后我在这一行收到错误 - deactivateAppForDuration(5);
代码是:
var target = UIATarget.localTarget();
......
......
target.deactivateAppForDuration(5);
错误是:
[UIElementNil prepareForAction]...
过程:我的应用程序在 safari 中打开 link,然后我的应用程序进入后台,现在 5 秒后我想将我的应用程序带回前台。
问题是 iOS9 上的不同 UI 布局(相对于 iOS7、iOS8),在您尝试切换回应用程序时显示: https://forums.developer.apple.com/thread/19047
如您所见,Apple 知道问题所在,但不会修复它。在尝试使用函数 deactivateAppForDuration() 将应用程序发送到 BG 一段时间后,它无法返回到 FG,并且总是抛出以下异常:
-[UIAElementNil _prepareForAction:]: unrecognized selector sent to instance
作为解决方法,我可以提出以下建议:
try {
UIATarget.localTarget().deactivateAppForDuration(time);
} catch (error) {
UIALogger.logMessage("Trying to perform workaround for iOS9");
// here you are tapping almost to the screen center and coming back to the app as result
UIATarget.localTarget().tap({origin:{x:35,y:140}, size:{width:99, height:70}});
}
当我在 ios 9 ipad 视网膜模拟器中 运行 我的自动化脚本 (UIautomation ios) 然后我在这一行收到错误 - deactivateAppForDuration(5); 代码是:
var target = UIATarget.localTarget();
......
......
target.deactivateAppForDuration(5);
错误是:
[UIElementNil prepareForAction]...
过程:我的应用程序在 safari 中打开 link,然后我的应用程序进入后台,现在 5 秒后我想将我的应用程序带回前台。
问题是 iOS9 上的不同 UI 布局(相对于 iOS7、iOS8),在您尝试切换回应用程序时显示: https://forums.developer.apple.com/thread/19047
如您所见,Apple 知道问题所在,但不会修复它。在尝试使用函数 deactivateAppForDuration() 将应用程序发送到 BG 一段时间后,它无法返回到 FG,并且总是抛出以下异常:
-[UIAElementNil _prepareForAction:]: unrecognized selector sent to instance
作为解决方法,我可以提出以下建议:
try {
UIATarget.localTarget().deactivateAppForDuration(time);
} catch (error) {
UIALogger.logMessage("Trying to perform workaround for iOS9");
// here you are tapping almost to the screen center and coming back to the app as result
UIATarget.localTarget().tap({origin:{x:35,y:140}, size:{width:99, height:70}});
}