I have multiple buttons with the same accessibilityID. I want to get the 3rd one.
Getting the first one is easy with
let severityItems = app.buttons["MyListItems"].firstMatch
But if I want the 3rd one and do it this way
let severityItems = app.buttons["MyListItems"].element(boundBy: 2)
I get an error: Value of type 'XCUIElement' has no member 'element'
Strange. I seems to get an array. If I po it in the debugger it shows me the elements correctly. How can I get the 3rd element?
CodePudding user response:
app.buttons["MyListItems"]
returns an XCUIElementQuery, not an array of elements. If you look at the documentation for that you'll see a property called allElementsBoundByIndex, which returns an array of elements.