Could you please help me to locate an element with regex in xpath?
I need locate id that is ‘any12symbols’ + ‘-’ + ‘index’
but regex is not recognized during TC execution
I use following xpath:
The matches(string, regex) function was added in the XPath 2.0 specification. Browsers only supports the XPath 1.0. You can not use any Regular Expression in XPath on browser. It is not a defect of Katalon Studio at all.
However you can write an XPath expression equivalent to an regexp using XPath 1.0 string functions: substring(s, pos, len), substring-before(s1, s2), substring-after(s1, s2), string-length(s), translate(s1, s2, s3) in combination.
Please note that the XPath expression in my sample Test Case works similar to the one you attempted with regex.
I think that it is not a big issue that we can not use the matches() function of XPath 2.0. We can always find an alternative expression without regex. You just want to get accustomed to utilizing XPath 1.0 String functions in combination.