API Find the Element of the Webpage

Find element using the API interface:

Request Url:

http://127.0.0.1:35000/api/v1/profile/findElement

Request Type: GET

NameTypeDescriptionrequired
profileIdstringBrowser profile IDtrue
functionstringfunctiontrue
argsstringargs is a parameter of function, example: findElementByID(args)true
clickstringWhether to click after finding the specified element
 true:Click  false:No Click
true
indexstringWhen there are multiple elements, specify which element to click. Starting at 0, minus 1 is one of the random elements, Used with ‘click = true’true


1. Find the elementID of the element using findElementByID, take Google as an example (id=APjFqb):

Body
x-www-form-urlencoded

{
    "profileId": "17D40B01-566A-4E3F-888A-C40A404668B8",
    "function": "findElementByID",
    "args": "APjFqb",
    "click": "false",
    "index": "-1"
}


2. Find the elementId of the element using the findElementByXPath, or take Google as an example, the args parameter is transmitted using base64 encoding, "Ly8qW0BpZD0iQVBqRnFiIl0=" decoded as: //*[@id="APjFqb"]:

{
    "profileId": "17D40B01-566A-4E3F-888A-C40A404668B8",
    "function": "findElementByXPath",
    "args": "Ly8qW0BpZD0iQVBqRnFiIl0=",
    "click": "false",
    "index": "-1"
}

The GET request above returns:

{"status":"OK","value":"{\"element-6066-11e4-a52e-4f735466cecf\":\"5B5FA39767AF484F74B9DF075F267113_element_2\"}"}

5B5FA39767AF484F74B9DF075F267113_element_2\ is the elementId to be used.


function parameter support:

findElementByID

findElementByTag

findElementByClassName

findElementByLinkText

findElementByXPath

findElementsByID

findElementsByTag

findElementsByClassName

findElementsByLinkText findElementsByXPath


Note:

(1) Enable browser automation settings on the VMLogin client when using the local interface and save the settings. Please refer to the tutorial "Launch the browser automation port";

(2) For profiled, please refer to the tutorial "Where is the profile ID" or use the profile/list interface to get all profileId.