在我的 UI 测试中,我有这个 XCUIElement
:
XCUIApplication().staticTexts["提交订单"]
当我打印 debugDescription 时:
po print(XCUIApplication().staticTexts["SUBMIT ORDER"].debugDescription)
有两个元素匹配:
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'
}
我的问题是:如何只在最后一个元素上制作 .tap()
?
最佳答案
您可以使用:
XCUIApplication().staticTexts.matching(identifier: "SUBMIT ORDER").allElementsBoundByIndex.last
关于swift - 访问 XCUIElement 中的最后一个元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59180278/