Remove special characters to a text output

The output of my actual text has special characters, I have tried to remove it using the code below and the console print in the actual value with no special characters.


But when I run my test scripts Katalon read the actual text as 85.0 %, and not follow the call of string named ‘test’
Is anyone have other options on removing special characters to an output of VerifyElementText?
Appreciate your help

Thank you

This line does not make sense at all.

WebUI.verifyElementText(TestObject, String) keyword expects an instance of com.kms.katalon.core.testobject.TestObject class as the 1st argument, as the document explains:

https://docs.katalon.com/katalon-studio/docs/webui-verify-element-text.html

But your code actuall specifies a variable named “test” which is an instance of java.lang.String.

Therefore this statement would not work at all.

(However, the screenshot you attached shows that Katalon Studio emits no error message about this wrong statement. Katalon Studio would have emitted some message to let you fix it. I wonder why.)

You seem to be thinking that “special character” has something to do with the incident. ---- No, not at all.

1 Like

WebUI.verifyElementText keyword always try to look up data in a HTML element. But now you want to look at the value of “test” variable. If you want to test if the “test” variable has the same value as a cell in the “Relative Humidity”, you should not use “WebUI.verifyElementText” keyword.

Rather, I would do

import com.kms.katalon.core.util.KeywordUtil
...
if (test != findTestData('Relative Humidity').getValue(3, 1)) {
    KeywordUtil.markFailedAndStop("test has unexpected value. test=" + test)
}

See also the javadoc of KeywordUtil class:

1 Like

Thank you so much Sir @kazurayam, it is now working :blush: I’ve also reviewed the documents attached and it help me a lot.

1 Like