Add variable value to xpath

I am reading data from CSV file.
value is stored in !col1 variable.

how do I add it to xpath?
I want to locate that element.

I tried this but its not working

Command
storeText

Target
//div[@data-filter-email=${!Col1}]

Value
Data

So you want to store the complete HTML code in a variable? Can you give an full example with a public website? Otherwise I do not understand what the goal is.

I want to get HTML code of a tag
for example
//div[@data-filter-email=’${!Col1}’]

here I am clicking div tag using attribute ‘data-filter-email’.

I want to extract complete HTML code of this tag
starting with <Div and ending with /div>

you can take any example, take header of the topic “Add variable value to xpath”
I am new to ui.vision so struggling as its my day 1.

Blockquote

I usually use variable in xpath and working like a charm

Probably you used a wrong xpath, try to detect better xpath

example
xpath=(//input[@type='checkbox'])[${!TIMES}]

single quotes were missing.

Now I want to extract HTML code of the element.

I also find it’s different from executeScript_Sandbox:
Below are all OK, //Variable ${!times} is mixed with String
2025-06-12T05:05:47.484Z - [info] Executing: | executeScript_Sandbox | return “//div[@id=‘searchResult’]/div[2]/div/div/div[2]/div/div/div[2]/div/div[1]/div[2]/div/div[${!times}]/table/tbody/tr/td[”+ (${colArr[2]}+1) +“]/div”; | xpathDR |
2025-06-12T05:05:48.129Z - [info] Executing: | storeText | ${xpathDR} | txtDR |
2025-06-12T05:05:48.474Z - [info] Executing: | click | //div[@id=“searchResult”]/div[2]/div/div/div[2]/div/div/div[2]/div/div[1]/div[2]/div/div[${!times}]/table/tbody/tr/td[1]/div/div[@class=“x-grid3-row-checker”] | |

I think you can’t do it with xPath. Instead you have to use executeScript and a javascript to get that info.

something like:
var myTagContent = document.getElementById(‘id_123’).getElementsByTagName(‘tr’)[1].getElementsByTagName(‘td’)[4].innerHTML;
return myTagContent;

and put that into a executeScript call

Note: you can use Kantu variables in your JavaScript:
var myTagContent = document.getElementById(‘id_123’).getElementsByTagName(‘tr’)[${!Col1}].