I would like to tap the last [Play] button in my app, and I'm looking for something like
app.buttons["play"].lastMatch.tap()
Is there any way to do so?
I managed this problem by writing a little extension
extension XCUIElementQuery {
var lastMatch: XCUIElement { return self.element(boundBy: self.count - 1) }
}
after that, I can simply write code like this
app.buttons.matching(identifier: "play").lastMatch.tap()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With