Find Element Text failed because of space

Hello,

In a window, I tried to find and to click on a value I get earlier in another window. It failed because in the second window, the value has a space.

String MySum = WebUI.getAttribute(findTestObject('Myobject'), 'value')
System.out.println(MySum)

Return the value 131,90€
But in the other page where this value is saved, it has this format : “131,91 €” (a space before the €).

So when I try to just verify if it is present, with :

WebUI.verifyTextPresent(MySum, true)

I get the error :

Test Cases/Test FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Unable to verify text '131,90€' is present  using regular expression

I understand the error. The value present in the second window is “131,90 €”, which is different to “131,90€”
So my question is : How can I click on the value “131,90 €” when I get “131,90€”.

Thanks for your help.

Try something like…

String MySum = WebUI.getAttribute(findTestObject('Myobject'), 'value')
MySum = MySum.split(/\€/)[0] + " €"
...
2 Likes

It works perfectly !!!
Thank you.
Now I have to fin how clik on it but this is an other question :sweat_smile:

thank you again !

1 Like