gpt4 book ai didi

iphone - 模拟 Home 按钮按下 - iPhone 测试

转载 作者:行者123 更新时间:2023-12-03 19:05:25 25 4
gpt4 key购买 nike

所以我正在测试一个 iPhone 应用程序。我正在尝试设置测试用例,以便稍后使用 UIAutomation 使用(我并没有真正受限于此 - 我可以切换到其他框架)。我基本上需要创建一个类似于以下内容的测试:

+ Launches application
+ Clicks a few specific buttons
+ Hits the home button exiting the application
+ Relaunches the application
+ Checks the status of the application

有谁知道如何执行此操作或使用什么框架来执行此操作?

提前致谢。

最佳答案

您无法模拟按下主页按钮,但您可以强制应用程序退出,就像按下一样。调用 [[UIApplication sharedApplication] Terminate]; 将终止应用程序或(在 iOS 4.x 的情况下)将应用程序置于后台。但是,您将无法使用 UIAutomation 重新启动应用程序。

您可以尝试将 UIAutomation 与屏幕录制脚本结合使用,该脚本允许您重放鼠标移动和单击。这将允许您直接与模拟器进行交互,例如单击主页按钮和单击应用程序图标。

或者,您可以使用 UIATarget class 获得“足够好”的测试。 。根据文档,

The UIATarget class represents high-level user interface elements of the system under test (SUT)—that is, your application, the iOS, and the connected device on which they’re running. Your test scripts, written in JavaScript and running in conjunction with the UI Automation instrument, use this class and related UIA classes to exercise the SUT and log results.

使用 UIATarget.localTarget().deactivateAppForDuration(seconds); 您可以让应用程序后台运行 n 秒。

Use this method to test shifting your application to and from the background execution context. Note that applications built using iOS SDK 4.0 or later and running in iOS 4.0 and later aren’t necessarily terminated when the user presses the Home button. See iOS Application Programming Guide for details of multitasking and background execution context.

关于iphone - 模拟 Home 按钮按下 - iPhone 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7000478/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com