我想在运行时获取 android 元素的资源 ID 和内容描述。
我试过这个:
myElement.getAttribute("resource-id")
myElement.getAttribute("content-desc")
但得到错误为" this element does not have the resource-id attribute
"。
有什么办法可以得到这个吗?
根据这篇文章,获得"content-desc"的方法是使用myElement.getAttribute("name").
用于资源 ID 使用:webElement.getAttribute("resourceId")
要获取内容描述,请使用:
myElement.getAttribute("contentDescription")