XCTest - 等待谓词失败

XCTest - Waiting for predicate fails

我正在尝试等待一个字符串在 UI 测试期间出现在导航栏中。尝试设置期望值时,我得到 "Thread 1: breakpoint 1.1"。我在这里做错了什么?

expectation(for: NSPredicate(format: "label CONTAINS 'Rent'"), 
    evaluatedWith: XCUIApplication().navigationBars.staticTexts, 
    handler: nil)
waitForExpectations(timeout: 10, handler: nil)

好的,我明白了。您需要一个元素而不是查询。所以代码应该是:

expectation(for: NSPredicate(format: "exists == 1"), 
  evaluatedWith: XCUIApplication().navigationBars.staticTexts.
  element(matching: NSPredicate(format: "label CONTAINS 'Rent'")), 
  handler: nil)
waitForExpectations(timeout: 10, handler: nil)