gpt4 book ai didi

xcode - UI XCTest, View 中存在的元素

转载 作者:可可西里 更新时间:2023-10-31 23:56:24 25 4
gpt4 key购买 nike

我是 UI 测试编写的新手。

我想知道是否有可能知道 View 中存在/存在哪些元素。我想知道它们的数量和名称。

我试过类似这样的方法来遍历所有元素,但它不起作用。

for element in app.accessibilityElements! {
print(element)
}

最佳答案

您正在寻找 XCUIElement 的 debugDescription 方法,在您的例子中是为了获取当前可见窗口的整个层次结构:

app.debugDescription

引用标题注释:

Provides debugging information about the element. The data in the string will vary based on the time at which it is captured, but it may include any of the following as well as additional data:

   • Values for the elements attributes.
• The entire tree of descendants rooted at the element.
• The element's query.

This data should be used for debugging only - depending on any of the data as part of a test is unsupported.

关于xcode - UI XCTest, View 中存在的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37003188/

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