XCUI测试失败,原因是异步等待失败:30秒超出超时,有达不到预期

问题描述 投票:1回答:2
 let webViewsQuery = app.webViews
    let emailOrPhoneTextField = webViewsQuery/*@START_MENU_TOKEN@*/.textFields["Email or phone"]/*[[".otherElements[\"Sign in – Google accounts\"].textFields[\"Email or phone\"]",".textFields[\"Email or phone\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/
    let exists = NSPredicate(format: "exists == TextField")
    expectation(for: exists, evaluatedWith: emailOrPhoneTextField, handler: nil)
    waitForExpectations(timeout: 30, handler: nil)
    emailOrPhoneTextField.tap()

异步等待失败:超过超时30秒,无法实现的期望:“期待的对象谓词exists == 1‘电子邮件或电话’文本字段”通过FASTLANE扫描运行时,

xcode8 xcode-ui-testing fastlane xcuitest
2个回答
1
投票

那是因为你从来没有满足您的期望(与expectation.fulfill()法)。使用XCTWaiter如果你不关心期待实现。


1
投票

这难道不是只是你需要让你的期望评价为真?

let exists = NSPredicate(format: "exists == true")

要么

let exists = NSPredicate(format: "exists == 1")
© www.soinside.com 2019 - 2024. All rights reserved.