跳到主要内容

WebSelector.find_all - 查找全部

WebSelector.find_all

查找所有满足条件的网页控件。

声明

node.web_selector(window):find_all(num)

参数

参数类型是否必填说明
numnumber最大返回数量,默认返回所有

返回值

类型说明
tableWebNode 数组
nil未找到
待实现

该接口正在开发中。

示例

local node = require("node")

local window = node.web_window("http://www.example.com")
local nodes = node.web_selector(window):tag("div"):find_all()

if nodes then
print("找到控件数量:", #nodes)
for i, n in ipairs(nodes) do
print(i, n.text)
end
else
print("没有找到任何控件")
end

AScript 对应

# AScript (Python)
from ascript.android.node import WebSelector
from ascript.android.ui import WebWindow

window = WebWindow("http://www.example.com")
nodes = WebSelector(window).tag("div").find_all()

if nodes:
print("找到控件数量:", len(nodes))
for node in nodes:
print(node.text)
else:
print("没有找到任何控件")