【问题标题】:Is it possible to operate with the last of matching elements in XCTest?是否可以使用 XCTest 中的最后一个匹配元素进行操作?
【发布时间】:2019-01-01 11:43:29
【问题描述】:

我想在我的应用中点按 last [播放] 按钮,我正在寻找类似的东西

app.buttons["play"].lastMatch.tap()

有什么办法吗?

【问题讨论】:

    标签: ios swift xcode xctest xcode-ui-testing


    【解决方案1】:

    我通过编写一个小扩展来解决这个问题

    extension XCUIElementQuery {
        var lastMatch: XCUIElement { return self.element(boundBy: self.count - 1) }
    }
    

    之后,我可以简单地写这样的代码

    app.buttons.matching(identifier: "play").lastMatch.tap()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-10-31
      • 2014-06-19
      • 1970-01-01
      • 1970-01-01
      • 2012-12-16
      • 2015-08-08
      • 2010-10-16
      • 1970-01-01
      相关资源
      最近更新 更多