當我運行下面的代碼測試:爲什麼NSPredicate accessibilityIdentifier失敗?
let shuffle = app.buttons.elementMatchingPredicate(NSPredicate(format: "accessibilityIdentifier=%@", "shuffle"))
expectationForPredicate(NSPredicate(format: "hittable=TRUE"), evaluatedWithObject: shuffle, handler: nil)
waitForExpectationsWithTimeout(2) {_ in}
shuffle.tap()
測試失敗。但是,當我使用此代碼:
let shuffle = app.buttons["shuffle"]
expectationForPredicate(NSPredicate(format: "hittable=TRUE"), evaluatedWithObject: shuffle, handler: nil)
waitForExpectationsWithTimeout(2) {_ in}
shuffle.tap()
http://www.bricepollock.com/difference-xcode-ui-testing-ui-automation-instrument/
這傢伙特別說了巨大的改進,以UIT在UIA是UIT使用了迅速評估每次使用時間的查詢,而不是評估一次並對結果集進行操作。這似乎是一個糟糕的設計原則。任何人都可以解釋第一個查詢有什麼問題嗎?
expectationForPredicate(NSPredicate("ANY accessibilityIdentifier=%@"), evaluatedWithObject: app.buttons)
似乎也沒有工作。是否有描述哪些函數是查詢和哪些是結果集的文檔?我只能在Apple的網站上找到1個頁面,介紹如何使用這個新的XCUI套件,並且它嚴重限制了示例。