2

In my UI Test, i have this XCUIElement :

XCUIApplication().staticTexts["SUBMIT ORDER"]

When i make a print debugDescription :

po print(XCUIApplication().staticTexts["SUBMIT ORDER"].debugDescription)

There is two element matching :

Find: Elements matching predicate '"SUBMIT ORDER" IN identifiers'
      Output: {
        StaticText, {{0.0, 623.0}, {375.0, 44.0}}, label: 'SUBMIT ORDER'
        StaticText, {{0.0, 623.0}, {375.0, 44.0}}, label: 'SUBMIT ORDER'
      }

My question is : How can i make a .tap() on the last element only ?

Kevin ABRIOUX
  • 16,507
  • 12
  • 93
  • 99

2 Answers2

7

You can do it using :

XCUIApplication().staticTexts.matching(identifier: "SUBMIT ORDER").allElementsBoundByIndex.last
cesarmarch
  • 617
  • 4
  • 13
2

Try this in your testFunc()

let app = XCUIApplication()

app.staticTexts.matching(identifier: "SUBMIT ORDER").allElementsBoundByIndex.last

Ronak Patel
  • 609
  • 4
  • 16