Using variables in xPaths

Hi there,
I am creating multiple elements in an xml with the same element name, and then trying to loop through them and update them. In my loop I have ‘Loop Number Name’ set to ‘loopNumber’. In a ‘Set XML Value’ Operation I am then trying to include that variable in the xPath as so:

="//element/element[loopNumber]"

and it isn’t working. How can I include the ‘loopNumber’ variable in my xPath?

Thanks

Hi,

In any input field in ORQA you can use a Groovy expression like this:

="//element/element[${loopNumber}]"

the exception is the “Run Short Script” operation which already assumes that the input is an expression. In “Run Short Script” operation you could then also use the above but without the = (equals sign). You would do this if you wanted e.g just to assign the value to a another variable.

If you do use = (equals) sign in the Run Short Expression operation it will execute the result of your expression ie you could put something like:

="println('test')"

which will will evaluate the expression and execute it so you’ll end up with “test” in your console.

Hope that helps

1 Like

Thanks very much, I have it working now!