Verify match does not seem to be working

Hi ,
I am new to Katalon. I am trying to match 2 totals(eg $23.72) displayed in the same page.
utton_SAVE CONTINUE’))

WebUI.click(findTestObject(‘Object Repository/Delivery2 OR/Page_Online Ordering/button_PLACE MY ORDER’))

WebUI.getText(findTestObject(‘Test 0R/Page_Online Ordering/span_23.72’))

WebUI.getText(findTestObject(‘Test 0R/Page_Online Ordering/span_23.72_1’))

WebUI.verifyMatch(‘Test 0R/Page_Online Ordering/span_23.72’,‘Test 0R/Page_Online Ordering/span_23.72_1’, true)

The error I get:


Unable to verify match between actual text ‘$23.72’ and expected text ‘$23.72’ using regular expression (Root cause: com.kms.katalon.core.exception.StepFailedException: Actual text ‘$23.72’ and expected text ‘$23.72’ are not matched using regular expression.
Test Cases/Orders/Delivery - Copy FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Actual text ‘$23.72’ and expected text ‘$23.72’ are not matched using regular expression
at com.kms.katalon.core.keyword.builtin.VerifyMatchKeyword$_verifyMatch_closure1.doCall(VerifyMatchKeyword.groovy:57)
at com.kms.katalon.core.keyword.builtin.VerifyMatchKeyword$_verifyMatch_closure1.call(VerifyMatchKeyword.groovy)
at com.kms.katalon.core.keyword.internal.KeywordMain.runKeyword(KeywordMain.groovy:68)
at com.kms.katalon.core.keyword.builtin.VerifyMatchKeyword.verifyMatch(VerifyMatchKeyword.groovy:60)
at com.kms.katalon.core.keyword.builtin.VerifyMatchKeyword.execute(VerifyMatchKeyword.groovy:45)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:73)
at com.kms.katalon.core.keyword.BuiltinKeywords.verifyMatch(BuiltinKeywords.groovy:73)
at Delivery - Copy.run(Delivery - Copy:90)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:339)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:330)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:309)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:301)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:235)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1616507502486.run(TempTestCase1616507502486.groovy:25)

In a regular expression, $ means match the end of the string. Now, ask yourself, how can 23.71 come after the end of the string?

You will either need to

  1. prefix '\' to the value: '\$23.71'
  2. remove '$' before doing the comparison

You wrote that you have a code:

WebUI.verifyMatch(‘Test 0R/Page_Online Ordering/span_23.72’,‘Test 0R/Page_Online Ordering/span_23.72_1’, true)

And you wrote that you got a message:

Unable to verify match between actual text ‘$23.72’ and expected text ‘$23.72’ using regular expression

I am puzzled here. If the doc is right, I think you should rather have gotten a message like this:

Unable to verify match between actual text ‘Test 0R/Page_Online Ordering/span_23.72’ and expected text ‘Test 0R/Page_Online Ordering/span_23.72_1’ using regular expression

Anyway, I suppose that you are calling WebUI.verifyMatch() with wrong parameters. The code should rather be like this:

String actual = WebUI.getText(findTestObject(‘Test 0R/Page_Online Ordering/span_23.72’))
String expected = WebUI.getText(findTestObject(‘Test 0R/Page_Online Ordering/span_23.72_1’))
WebUI.verifyMatch(actual, expected, false)

Thank you so much. This worked.