跳到主要内容

Element.Find 查找指定元素

🎯功能

查找当前界面指定元素属性

📜语法

结果 = Element.Find(class, text)

📥参数

参数数据类型解释
class字符串元素类名, 抓抓上元素抓取的class内容
text字符串元素文本, 抓抓上元素抓取的text内容

📤返回

, 返回找到的二维键值对信息, 格式为{ {"resource-id":资源id, "class":类名, "text":文本, "left":左上角x, "top":左上角y, "right":右下角x, "bottom":右下角y}, ...}, 没找到的话, 键值对中文本为"", 数值为-1

💡示例

Dim Table, iId, sClass, sText
Dim iLeft, iTop, iRight, iBottom
Table = Element.Find("android.widget.TextView", "推荐游戏")
TracePrint Encode.TableToJson(Table)
If Len(Table) > 0 Then
//获取第一个元素属性内容
iId = Table[1]["resource-id"] //没数据为空 ""
sClass = Table[1]["class"] //没数据为空 ""
sText = Table[1]["text"] //没数据为空 ""
iLeft = Table[1]["left"] //没数据为 -1
iTop = Table[1]["top"] //没数据为 -1
iRight = Table[1]["right"] //没数据为 -1
iBottom = Table[1]["bottom"] //没数据为 -1
TracePrint iId
TracePrint sClass
TracePrint sText
TracePrint iLeft
TracePrint iTop
TracePrint iRight
TracePrint iBottom
End If

📘备注

  • 仅支持安卓5.0及以上系统版本