My Object identification is something like this;
/dom[@domain='something.com']//ul[#'bodyForm:messages']/?/?/span[@innertext~'^Hours\ per\ week:\ ''xx''\ is\ n']
How can I replace "XX" with a variable?
Thanks.
How to use a variable in xpath string
Re: How to use a variable in xpath string
Try this:
Notice the single-ticks inside the double-ticks.
Just add <' + $myVariable + '> (without the <> brackets) in place of the XX in your path. XPath strings are single-tick so you break your @innertext match string with those and add the concatenation operator (+) around the variable.
Code: Select all
/dom[@domain='something.com']//ul[#'bodyForm:messages']/?/?/span[@innertext~'^Hours\ per\ week:\ ''' + $myVariable + '''\ is\ n']
Just add <' + $myVariable + '> (without the <> brackets) in place of the XX in your path. XPath strings are single-tick so you break your @innertext match string with those and add the concatenation operator (+) around the variable.
Shortcuts usually aren't...