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

Lal*_*ith 4 iphone ui-automation ios ios-ui-automation

我是IOS编程的新手.我有一个任务是找到我是否可以自动化我的UI进行测试.这就是我想要做的:

  • 在我的应用程序中随机放置一些代码(听起来不好但可能是预定义的事件)将事件消息发送到屏幕上的控件.

  • 由于它只是代码,我应该能够使用该应用程序,将其部署在任何iPhone或iPad中并运行该程序.

  • 一旦应用程序通过我的代码完全自动化,我想可以很容易地对获得的性能数据进行分析.

我见过FoneMonkey,但看起来需要在每台设备上手动记录用户交互.

欢迎任何想法或建议.

  • Lalith

Rui*_*res 5

您好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];
    }
Run Code Online (Sandbox Code Playgroud)

编辑2:

if([myTextField canBecomeFirstResponder]){
    [myTextField becomeFirstResponder];
}
Run Code Online (Sandbox Code Playgroud)