Description
When building bots, we can benefit from getting information from a list on a website. Here you will learn how to do a loop using XPath to obtain such a list.
This procedure is useful in order to get multiple elements inside a loop. Also, with the number of items on hand, you can use it to extract them in another activity. So, let us see the steps.
Instructions
Here’s how to do it in a few easy steps:
-
Insert in the workflow a Do-While loop activity
-
Insert in the workflow the Get element Property activity
-
Get the Full XPath to the element on the website:
- Now, select a similar element (in this example, the “Five apps to use…” header). Copy both paths to Notepad to discern the difference. In this example, we see the following:
/html/body/div[7]/div/div[10]/div/div[2]/div[2]/div/div/div/div/div[1]/div/div/a/div/div[2]/div[2]
/html/body/div[7]/div/div[10]/div/div[2]/div[2]/div/div/div/div/div[2]/div/div/a/div/div[2]/div[2] - We can see the specific DIV that changed the value from the first heading to the second. Now we can create an element with this dynamically.
With this workflow, you are able to get the elements from this list while running the loop, This is the final result:
The Result:
In this case, as we display the result in the Console, but you could also save it to a variable or a database.