gpt4 book ai didi

ios - 你如何在 Swift/iOS 的 UI 测试中遍历元素?

转载 作者:可可西里 更新时间:2023-11-01 01:00:05 26 4
gpt4 key购买 nike

我明白我可以怎样做,例如查看表格中的一个元素,但是简单地遍历所有元素的正确方法是什么,无论找到多少元素,例如点击它们?

让 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com