推送新视图控制器后,UIAutomation测试失败(tuneup.js)

时间:2012-10-06 00:31:03

标签: ios ui-automation ios-ui-automation

我刚开始用tuneup.js尝试UIAutomation。我可以很好地测试我的第一个窗口,但是第二个窗口失败了 - 我的应用程序仍在查看第一个窗口并看到例如“使用Facebook登录”按钮。我试过添加延迟,但这似乎没有帮助。对我做错了什么的想法?

#import "tuneup.js"

target = UIATarget.localTarget();
application = target.frontMostApp();

test("Test first-run view controller", function(app, target) {
 assertWindow({
              buttons : [
                         { name : "Sign in with Facebook"},
                         { name : "Create account"},
                         { name : "Login"},
                         { name : "Try"}
              ], 
              onPass: function(window) {

                var createAccountButton = window.buttons()["Create account"]
                createAccountButton.tap();
              }

 });

});

test("Test Sign-in screen", function(app, target) {
 assertWindow({
    buttons : [
              { name : "Sign up"}
        ]
 });

 });

1 个答案:

答案 0 :(得分:0)

啊,我发现了发生了什么事。我没有意识到,但我的登录屏幕有一个包含其按钮的滚动视图。这段代码运行良好:

test("Test the account creation", function(app, target) {
 assertWindow({
              scrollViews: [
                    { buttons : [
                            {name :"Sign up"},
                            {name : "Terms and Conditions"}
                            ]

              }
                            ],
              onPass: function(window) {
                var signUpButton = window.scrollViews()[0].buttons()["Sign up"];
                signUpButton.tap()
              }
 });

 });