2017-03-22 34 views
1

在UITest中,点击登录按钮后,我需要等待两个事件,登录成功后才会显示更新或主屏幕,并决定如何操作。 文档说,即XCTest waitForExpectations(...)等待多个结果

只有一个-waitForExpectationsWithTimeout:处理程序:可以在任何给定的时间活性,但{期望 - >等待} *多个分立序列可以被链接在一起。

所以需要努力一下,但最后想通了。

回答

0

您可以将参数添加到谓词并在条件之间使用“或”。

let skipUpdateButtonPredicate = NSPredicate(format: "%@.exists == 1 OR %@.exists == 1", skipUpdateButton, homeTabBar) 
self.expectation(for: skipUpdateButtonPredicate, evaluatedWith: [Any](), handler: nil) 
testCase.waitForExpectations(timeout: Constants.loginTimeout, 
           handler: nil) 

然后你就可以在这里分支,如果家里或更新提出:

if skipUpdateButton.exists { 
    skipUpdateButton.tap() 
}