Can you anyone know how to use translate method in Xpath

//span[(contains(text(), ‘CHC’) or contains(., ‘CHC’))] - How to use translate in this?

what do you want to translate? good source for how translate fn is working can be found here:

Do you want to translate ‘chc’ and ‘Chc’ in the text() to ‘CHC’ and then check if the text() contains ‘CHC’?

Then the following code will do it:

//span[contains(translate(text(), 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'), 'CHC')]
1 Like

shorter would be use matches() fn:


personaly i cannot come with useful example for translate (but that definitely does not mean there is no such case, that just mean i’m not capabe to come up with something)

Does xpath matches() function works in Katalon? I don’t think so. PLS have a look at this post:

yup, you are right… matches is not working …

to @Katalon team

I would say again. As I mentioned in the previous post, Katalon should consider removing the Condition “matches regex” completely.