使用API接口Find Element(寻找网页中的元素):
Request Url:
http://127.0.0.1:35000/api/v1/profile/findElement
Request Type: GET
名称 | 类型 | 描述 | 必传 |
profileId | string | 浏览器配置文件ID | true |
function | string | function函数 | true |
args | string | 参数为 function函数的传参,如:findElementByID(args) | true |
click | string | 找到指定元素后是否点击操作 true:点击 false:不点击 | true |
index | string | 元素有多个时,指定点击第几个元素。从0开始,-1 为随机元素其中一个,配合 click = true 时使用 | true |
1. 使用findElementByID找元素的elementID,以google为例(id=APjFqb):
Body
x-www-form-urlencoded
{
"profileId": "17D40B01-566A-4E3F-888A-C40A404668B8",
"function": "findElementByID",
"args": "APjFqb",
"click": "false",
"index": "-1"
}

2. 使用findElementByXPath 方法找元素的 elementId ,还是以google为例,args 参数使用 base64 编码传输,"Ly8qW0BpZD0iQVBqRnFiIl0=" 解码后是://*[@id="APjFqb"]:
{
"profileId": "17D40B01-566A-4E3F-888A-C40A404668B8",
"function": "findElementByXPath",
"args": "Ly8qW0BpZD0iQVBqRnFiIl0=",
"click": "false",
"index": "-1"
}
上边的GET请求会返回:
{"status":"OK","value":"{\"element-6066-11e4-a52e-4f735466cecf\":\"5B5FA39767AF484F74B9DF075F267113_element_2\"}"}
其中5B5FA39767AF484F74B9DF075F267113_element_2\就是要用到的elementId.

function参数支持:
findElementByID
findElementByTag
findElementByClassName
findElementByLinkText
findElementByXPath
findElementsByID
findElementsByTag
findElementsByClassName
findElementsByLinkText findElementsByXPath
注:
(1)使用本地接口时,需在客户端启动“浏览器自动化设置”并保存设置,教程请参考“开启浏览器自动化端口”;
(2)profileId请参考“配置文件ID(Profile ID)在哪”教程或者使用profile/list的api接口获取所有profileId。