Is there any way to capture all similar elements based on XPath



Hi there

I need to extract an element via Xpath from a website,
first element Xpath is
second element Xpath is

and so on…u can see the pattern, for subsequent values only number inside one of the div[x] is changing

I have added a web element(after Open website) where I have added first Xpath, and have
then stored this value in to Recorder variable “Price”. This is okay. But if I have to capture say 5
values do I need to create 5 Web Element and provide each Xpath individually, or is there any
other short cut method to repeat above step 5 times where it just change the value of x inside div[x]

Any suggestions, I have also read about Variable List, but not able to understand how it can be used
, do it work only in case of li i.e. List, is there any video that shows this ?



Try and see if you can use * in place of the numbers specified next to the div.

So instead of:


According to the docs for Workfusion 1.1.2, you should be able to store what your grab from an xpath to an array instead of an individual variable like a string, so grabbing elements with an asterisk (*) instead of an exact number may grab all of the matching xpaths in the document and store them in an array.

If this works, it should only grab as many price divs as there are on the page, making this solution scalable. You’ll just need to figure out a clever way to only use the first 5 results returned.

This is how it works in Python, at least.


No, using asterisk (*) is not working fine. It is picking some other value in this case.


use a variable instead of the asteriks


Yes I have tried to create a Recorder variable and added with a value equal to ‘2’ for instance. But it is not working. Thanks


Can you share your recording or a screenshot with the action and the variable&



Attached zip file contains:

a. this is the complete recording of the process I am doing.

Target is to go to Amazon, search for ipad which are new, and capture name of 5 seller and corresponding prices. Approach that I want to adapt is to create a generic Xpath, through which values can be store (like an array) and can be used further (as we are already discussing).

b. AssignmentOutput.csv, this is the file where output is store, this file currently has output when I have used asterisk in Xpath

c. Issue with Asterisk.jpg is to show you step and place where asterisk was used

d. Error-WhenVariableUser.jpg is the error received when I have used Recorder variable, instead of asterisk in the Xpath.

To (2.0 MB)

If you can modify and provide the recording according with explanation it will really help…



a. use list variable (price) and another xpath -
//div[contains(@class, ‘a-column a-span2 olpPriceColumn’)]/span[1]

this will result in getting all prices to list variable,

b. You can output any data to excel, use excel actions for it

c. If you use string as output - you will get only 1 found element
If you want all of them - use list output variable

d. currently we do not support variables there



Thanks, can you tell from where you were able to get this XPATH, this is different from XPATH that I have captured by usual approach of inspect element, and copy XPATH function.

Can you suggest similar way to find XPATHs of corresponding Sellers ?

Second, this XPATH is able to capture all prices in variable ‘price’ (of type list) , but it is saving all prices together like below:

[$330.99, $330.99, $331.00, $331.00, $331.00, $332.00, $332.00, $327.48, $325.38, $334.99]

I have created loop where I want to save one value at a time (may be based on index number), but RPA express does not provide any function to add variable for index, instead a hard number is to be passed.

Any way to resolve it like

for(int I=0;i<5;i++)
Enter Keystrokes from Variable 'price’
Index #: " i "


So literally for each value “I”, it will add only one price.


  1. There is no plugin that will help to get “Smart” Xpath, best solution here is:
  2. You can use filter in “For Each” action



Thanks for your guidance.

I am now approaching the problem with ForEach per your suggestion, and for this please check my question with the screenshot (with comments) given below. Here I am trying to open a notepad based on the ranges given in Filter (for example say 1-5) and then trying to write the value stored in price in notepad. So, for each iteration a new notepad will open and a price will be written on it.

But issue is that Enter keystroke - From Variable does not give flexibility to increase or change “index#” automatically based on any other Variable. So, if I add “index#”, same will be repeated for all each time loop runs. More is explained in screenshot please check and suggest.



Hi mzhalniarkevich

Can you help me in above issue ?



Lets say you have 3 prices in list “price”

  1. All your script will be executed 3 times (for each variable in list), in your case it will open notepad 3 times
    So, place notepad open actions outside the “For Each” loop
  2. You want to print each item in List, not the list “price” itself
    so it should look like:

Once again, “For Each” breaks list into items (variable item), which is each record of the list
Once it executes everything with first item it takes second item and executes it.


Hi I have same issue, I need to grad values from tabular format, Using variables in XPath is not allowing, in case if we go using list option, it might not give accurate data for each record.

Any suggestions to overcome this ?



If list does not work in your case, do it 1 by one

Or you can show me the webpage with data you need. Maybe there is a solution with list


Hers the page I’m working on, I need to collect the data(Denomination, TalkTime Range Value (Rs), Validity (days), Category) 1 row at a time and make some external operations then repeat the same for all available rows.

Xpath for each required column.



You would probably need to have separate lists for Denomination, TalkTime etc. and fill each of them with its own XPath. Afterwards, you can put your lists into separate Excel columns.

In the next steps, you can read the Excel data by row and perform your operations.

I hope it helps.



To have variable in XPath please vote for it here :


this feature is planned for the 1.1.5 release which comes at the end of August.


Get more information regarding XPath in RPA Express here: