Issue with verify showing same values but showing as failed

I am running a test and I keep getting an error that the text values don’t match when they actually do.

Here is the line of code:
WebUI.verifyEqual(WebUI.getText(findTestObject(‘Object Repository/Page_MyLicense Office -admin/FeeStatusUnpaid’)),’ Unpaid’)

Here is the error:
06-11-2019 11:18:52 AM verifyEqual(getText(findTestObject(“Object Repository/Page_MyLicense Office -admin/FeeStatusUnpaid”)), " Unpaid")

Elapsed time: 0.081s

Unable to verify equal between actual object ’ Unpaid’ and expected object ’ Unpaid’ (Root cause: com.kms.katalon.core.exception.StepFailedException: Actual object ’ Unpaid’ and expected object ’ Unpaid’ are not equal
at com.kms.katalon.core.keyword.builtin.VerifyEqualKeyword$_verifyEqual_closure1.doCall(VerifyEqualKeyword.groovy:58)
at com.kms.katalon.core.keyword.builtin.VerifyEqualKeyword$
at com.kms.katalon.core.keyword.internal.KeywordMain.runKeyword(KeywordMain.groovy:68)
at com.kms.katalon.core.keyword.builtin.VerifyEqualKeyword.verifyEqual(VerifyEqualKeyword.groovy:63)
at com.kms.katalon.core.keyword.builtin.VerifyEqualKeyword.execute(VerifyEqualKeyword.groovy:44)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)
at com.kms.katalon.core.keyword.BuiltinKeywords.verifyEqual(BuiltinKeywords.groovy:141)
at Checklist Requirements Requirements Person:110)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(
at com.kms.katalon.core.main.TestCaseExecutor.runScript(
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(
at com.kms.katalon.core.main.TestCaseExecutor.execute(
at com.kms.katalon.core.main.TestCaseMain.runTestCase(
at com.kms.katalon.core.main.TestCaseMain$runTestCase$ Source)

This may be a bug in Katalon’s keyword, but to test it, try executing this code:

assert WebUI.getText(findTestObject(“Page_MyLicense Office -admin/FeeStatusUnpaid”)).equals(“ Unpaid”)

(Nice profile pic btw :sunglasses:)

that worked. thank you sir.

should I put this in as a bug then because other verifyequal work? very strange

thanks for the profile pic compliment. :slight_smile:

good to know there are other fans out here

No need, I will move it for you. At least you have a workaround for now :slight_smile:

It is likely that a text extracted from HTML is prepended/appended with whitespace characters (space,CR,LF,TAB). You should trim those whitespaces before making a strict assertion:

def expected = "Unpaid"
def actual = WebUI.getText(findTestObject("Page_MyLicense Office -admin/FeeStatusUnpaid"))
assert actual.trim().equals(expected)

Or alternatively use .contains() rather than .equals() for a tolerant assertion.

def expected = "Unpaid"
def actual = WebUI.getText(findTestObject("Page_MyLicense Office -admin/FeeStatusUnpaid"))
assert actual.contains(expected)

Sometimes Non-breaking space character(or   \u00a0 in UNICODE) in HTML make things more complicated.

1 Like

I closed it as it is inactive.