IOS 中是否有用于 UI 控件自动化的现有库

发布于 2024-11-25 12:45:02 字数 1536 浏览 2 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

无法言说的痛 2024-12-02 12:45:02

你好,Lalith,我一直在为应用程序创建一些 UI 自动化测试,并且运行得很好。虽然它有一些技巧,但我认为您应该看看这些链接:

http://answers.oreilly.com/topic/1646-how-to-use-uiautomation-to-create-iphone-ui-tests/

http://alexvollmer.com/posts/2010/07/03/working- with-uiautomation/

如果您需要更多帮助,请告诉我。 :)

Edit1:

在 viewController 的 viewDidLoad 上,您可以添加如下内容:

   - (void)viewDidLoad {
        [super viewDidLoad];
        //(Your code...)
        // I set it to start after 5 seconds...
        [self performSelector:@selector(startTest) withObject:nil afterDelay:5];
     }


   -(void)startTest{
      //took this from the link you posted
      [myButton sendActionsForControlEvents:UIControlEventTouchUpInside];
    }

编辑 2:

if([myTextField canBecomeFirstResponder]){
    [myTextField becomeFirstResponder];
}

Hello Lalith i have been creating some UI Automation tests for an application and its working very well. Although it has some tricks, I think you should take a look at these links:

http://answers.oreilly.com/topic/1646-how-to-use-uiautomation-to-create-iphone-ui-tests/

http://alexvollmer.com/posts/2010/07/03/working-with-uiautomation/

If you need more help, just let me know. :)

Edit1:

On your viewDidLoad of your viewController you can add something like this:

   - (void)viewDidLoad {
        [super viewDidLoad];
        //(Your code...)
        // I set it to start after 5 seconds...
        [self performSelector:@selector(startTest) withObject:nil afterDelay:5];
     }


   -(void)startTest{
      //took this from the link you posted
      [myButton sendActionsForControlEvents:UIControlEventTouchUpInside];
    }

Edit 2:

if([myTextField canBecomeFirstResponder]){
    [myTextField becomeFirstResponder];
}
两个我 2024-12-02 12:45:02

Apple 有一个通过仪器和可访问性 API 实现基于 javascript 的自动化的框架。它不是 100% 最好的,但值得一看。

仪器 + 用手指实际触摸手机也是“在现实世界中”进行性能分析的一种非常好的方法。

一般来说,我认为自动化 UI 测试不值得。 UI 通常变化太大,以至于功能规范的工作量低于其价值。 YMMV。

Apple has a framework for javascript-based automation via instruments and the accessibility APIs. It's not 100% awesome the best, but it's worth taking a look.

Instruments + actually touching the phone with your finger is a pretty good way to do performance analysis "in the real world" as well.

Generally, I haven't found it worthwhile to automate UI testing. The UI generally changes too much to make a functional spec less work than it's worth. YMMV.

梦行七里 2024-12-02 12:45:02

一旦您达到了满意的程度,我就会看看这个 KIF 框架

KIF 代表 Keep It Function,是一个 iOS 集成测试
框架。它允许通过利用
操作系统为具有以下权限的用户提供的可访问性属性
视力障碍。

Once you get to a point you are comfortable, I would look at this KIF framework.

KIF, which stands for Keep It Functional, is an iOS integration test
framework. It allows for easy automation of iOS apps by leveraging the
accessibility attributes that the OS makes available for those with
visual disabilities.

梦途 2024-12-02 12:45:02

您可以创建一个父 UIView,向其中添加“子视图”或子视图。子视图包含您的应用程序 UI。

父视图设置为透明,它捕获触摸并记录它们。记录后,触摸事件将传递到子视图。您可以将您的测试结果发送到此处。

由于父视图是透明的,用户永远看不到它,但它仍然捕获并处理触摸事件。

设置此功能将涉及大量子类化,并且某些类(例如 UIWebView)会带来困难。但这可能是可行的。

You could create a parent UIView, to which you add "children" or subviews. The subviews contain your application UI.

The parent view is set up to be transparent, and it captures touches and logs them. Once logged, the touch event is passed down to the subviews. You could send your test touches here.

Because the parent view is transparent, the user never sees it, but it still captures and processes touch events.

Setting this up would involve a fair amount of subclassing, and some classes (such as UIWebView) introduce difficulties. But it might be feasible.

伤感在游骋 2024-12-02 12:45:02

感谢您的帮助。正如我在评论中提到的,我应该能够在 IOS 设备中独立运行它们。我们可以按照此处所述使用sendActionsForControlEvents。
这就是我现在所需要的。

Thanks for all your help. As I have mentioned in a comment that I should be able to run them in IOS device as stand alone. We can use sendActionsForControlEvents as described here .
This is all I need for now.

随风而去 2024-12-02 12:45:02

您可以考虑SeeTest from Experitest,它具有非常简单的记录和重播功能。

You can consider SeeTest from Experitest, it comes with very easy record and replay capabilities.

椒妓 2024-12-02 12:45:02

我在 iOS 自动化中使用 IMAT 非常成功。

https://code.intuit.com/sf/sfmain/do/viewProject /projects.ginsu

我喜欢它的原因:

  1. 它构建在 Apple 提供的 javascript 自动化之上,您可以从 Instruments 或命令行启动它
  2. 它为 javascript 提供了一个测试运行器(想想 N-Unit) iOS 自动化
  3. 提供了一种简洁的机制来检索 UI 元素(类似于其他自动化工具使用的对象映射)
  4. 无需更改您的应用程序代码(无需使用特定库进行构建或检测您的代码)
  5. 在运行后提供类似于 jUnit 的报告通过读取 plist 文件进行测试运行,这是由我的 CI 工具(Teamcity、Jenkins、CruiseControl)获取的

I've been using IMAT quite successfully for iOS automation.

https://code.intuit.com/sf/sfmain/do/viewProject/projects.ginsu

Reasons I like it:

  1. It's built right on top of the javascript automation that Apple provides and you can kick it off from Instruments or command line
  2. It provides a test-runner (think N-Unit) for javascript iOS automation
  3. Provides a neat mechanism for retrieving UI Elements (similar to an object map used by other automation tools)
  4. Requires no changes to your app code (no need to build with a certain library or instrument your code)
  5. Provides a jUnit like report after a test run by reading the plist file and this is picked up by my CI Tool (Teamcity, Jenkins, CruiseControl)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文