Possible bug in times command ${!times} when looping xpath

variable interpolation/parsing issue

times loop variable interpolation truncates XPath expressions containing ${!times}`

  1. UI.Vision RPA version: ( 9.6.1 )
  2. Chrome Browser: Version 150.0.7871.125 (Official Build) (64-bit)
  3. OS: Windows (Windows 10 Pro 22H2)

When using ${!times} inside an XPath locator, the generated XPath is sometimes truncated during execution.

Example intended XPath:

xpath

//*[@id=x‘birthday’]/div/div/span[${!times}]/a/span/b
Expected after substitution
//*[@id=‘birthday’]/div/div/span[3]/a/span/b

Actual behavior observed: after 2nd iteration (iteration 1 works as expected, iteration 2 onward is truncated)

//*[@id=‘birthday’]/div/div/span[3]/a/span (the /b is truncated)

or Command storeAttribute

//*[@id=‘birthday’]/div/div/span[4]/a/span@class
works on 1st iteration becomes truncated on 2nd iteration onward

//*[@id=‘birthday’]/div/div/span[4]/a/span

I switched to the internal loop ${!loop} and the issue went away. The xpaths are not truncated.

When testing I added the xpaths to a variable and then expanded the variables during runtime, however the xpaths were still truncated on the 2nd iterations onward.

Working Code

{
“Name”: “user class-4”,
“CreationDate”: “2026-7-17”,
“Commands”: [
{
“Command”: “store”,
“Target”: “true”,
“Value”: “!errorignore”,
“Description”: “”
},
{
“Command”: “store”,
“Target”: “1”,
“Value”: “!timeout_wait”,
“Description”: “”
},
{
“Command”: “if”,
“Target”: “${!loop} == 1”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “store”,
“Target”: “Happy Birthday!!! :yay:”,
“Value”: “message”,
“Description”: “”
},
{
“Command”: “end”,
“Target”: “”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “comment”,
“Target”: “store // xpath=//[@id=‘birthday’]/div/div/span[${!loop}]/a/span/b",
“Value”: “xpUser”,
“Description”: “”
},
{
“Command”: “storeText”,
“Target”: "xpath=//
[@id=‘birthday’]/div/div/span[${!loop}]/a/span/b”,
“Value”: “xpUser”,
“Description”: “”
},
{
“Command”: “store”,
“Target”: “${xpUser}”,
“Value”: “username”,
“Description”: “”
},
{
“Command”: “executeScript_Sandbox”,
“Target”: “return ${username}.replace(/^“|”$/g,‘’).trim();”,
“Value”: “username”,
“Description”: “”
},
{
“Command”: “store”,
“Target”: “xpath=//[@id=‘birthday’]/div/div/span[${!loop}]/a/span@class",
“Value”: “xpClass”,
“Description”: “”
},
{
“Command”: “storeAttribute”,
“Target”: “${xpClass}”,
“Value”: “userClass”,
“Description”: “”
},
{
“Command”: “executeScript_Sandbox”,
“Target”: “return ${userClass}.replace(/^“|”$/g,‘’).trim();”,
“Value”: “userClass”,
“Description”: “”
},
{
“Command”: “executeScript_Sandbox”,
“Target”: “return ${message} + ’ <> [’ + ${userClass} + ‘_bold]@’ + ${username} + ‘[/’ + ${userClass} + ‘_bold] :yay:’;”,
“Value”: “message”,
“Description”: “”
},
{
“Command”: “echo”,
“Target”: “${message}”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “if”,
“Target”: “${!loop} == 9”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “selectFrame”,
“Target”: “relative=top”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “selectFrame”,
“Target”: “index=0”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “type”,
“Target”: "xpath=//
[@id=‘inputField’]”,
“Value”: “${message}”,
“Description”: “”
},
{
“Command”: “end”,
“Target”: “”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “comment”,
“Target”: “verifyElementPresent // xpath=//*[@id=‘birthday’]/div/div/span[3]/a/span/b”,
“Value”: “”,
“Description”: “”
}
]
}

Echo Message Result (bbCode)

Happy Birthday!!!! :yay: <> [user_bold]@Funkadhafi[/user_bold] :yay: <> [power_user_bold]@kdev7[/power_user_bold] :yay: <> [power_user_bold]@morbiddk[/power_user_bold] :yay: <> [power_user_bold]@papito[/power_user_bold] :yay: <> [elite_user_bold]@Scarecrow[/elite_user_bold] :yay: <> [user_bold]@seventill3[/user_bold] :yay: <> [user_bold]@SexyHick[/user_bold] :yay: <> [user_bold]@Viperions[/user_bold] :yay: <> [power_user_bold]@voox2200[/power_user_bold] :yay:

There are a few other instances where I use “times“ to iterate through xpaths where I get many #LNF returned but I haven’t analyzed those as the results were not critical and the erros were ignored. When I get a chance I’ll check to see if the same behavior is seen.

Summary
in this use case the xpath are getting truncated on the 2nd iterations whether using the raw xpath or by extrapilating the xpaths from a variable. Just curious if this is a bug.

BTW, I still have the nonworking code if you’d like to see that as well.

Thank you.
de Plane

Do you have a test macro for us? we can not recreate the issue here.

Here is a version of the macro that did not work and exhibits the error I explained in my post.
The webpage is a private site and requires login. However the code should run with just about any page by updating the xpaths.

{
“Name”: “user class-3”,
“CreationDate”: “2026-7-22”,
“Commands”: [
{
“Command”: “storeXpathCount”,
“Target”: “xpath=//[@id=‘birthday’]/div/div/span",
“Value”: “birthdayCount”,
“Description”: “”
},
{
“Command”: “echo”,
“Target”: “Found ${birthdayCount} birthday users”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “comment”,
“Target”: “times // 4”,
“Value”: “”,
“Description”: “${birthdayCount}”
},
{
“Command”: “store”,
“Target”: “true”,
“Value”: “!errorignore”,
“Description”: “”
},
{
“Command”: “store”,
“Target”: “1”,
“Value”: “!timeout_wait”,
“Description”: “”
},
{
“Command”: “storeText”,
“Target”: "xpath=//
[@id=‘birthday’]/div/div/span[${!loop}]/a/span/b”,
“Value”: “xp”,
“Description”: “”
},
{
“Command”: “store”,
“Target”: “${xp}”,
“Value”: “username”,
“Description”: “xpath=//[@id=‘birthday’]/div/div/span[${!times}]/a/span/b"
},
{
“Command”: “executeScript_Sandbox”,
“Target”: “return ${username}.replace(/^“|”$/g,‘’);”,
“Value”: “username”,
“Description”: “”
},
{
“Command”: “store”,
“Target”: "xpath=//
[@id=‘birthday’]/div/div/span[${!loop}]/a/span@class”,
“Value”: “xpp”,
“Description”: “”
},
{
“Command”: “storeAttribute”,
“Target”: “${xpp}”,
“Value”: “userClass”,
“Description”: “xpath=//[@id=‘birthday’]/div/div/span[${!times}]/a/span@class"
},
{
“Command”: “executeScript_Sandbox”,
“Target”: “return ${userClass}.replace(/^“|”$/g,‘’);”,
“Value”: “userClass”,
“Description”: “”
},
{
“Command”: “executeScript_Sandbox”,
“Target”: “return ‘[’ + ${userClass} + ‘_bold]@’ + ${username} + ‘[/’ + ${userClass} + ‘_bold]’;”,
“Value”: “message1”,
“Description”: “”
},
{
“Command”: “store”,
“Target”: "${message1} Happy Birthday!!! :yay: ",
“Value”: “message”,
“Description”: “”
},
{
“Command”: “echo”,
“Target”: “${username} | ${userClass} | ${message}”,
“Value”: “blue”,
“Description”: “”
},
{
“Command”: “selectFrame”,
“Target”: “relative=top”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “selectFrame”,
“Target”: “index=0”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “type”,
“Target”: "xpath=//
[@id=“inputField”]”,
“Value”: “${message}<>”,
“Description”: “”
},
{
“Command”: “pause”,
“Target”: “”,
“Value”: “”,
“Description”: “”
}
]
}

Best Regards,
dePlane

it is a comment

have you tested without commenting and you will need END statement too