我明白我可以怎样做,例如查看表格中的一个元素,但是简单地遍历所有元素的正确方法是什么,无论找到多少元素,例如点击它们?
让 indexFromTheQuery = tables.staticTexts.elementBoundByIndex(2)
最佳答案
好的,我成功地找出了简单的语法。我刚刚开始使用 Swift,所以我花了很长时间才想到答案。
此代码有效:
var elementLabels = [String]()
for i in 0..<tables.staticTexts.count {
elementLabels.append (tables.staticTexts.elementBoundByIndex(i).label)
}
print (elementLabels)
关于ios - 你如何在 Swift/iOS 的 UI 测试中遍历元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35521704/