Hello Team,
I am facing an issue with text verification on Safari. I am trying to verify the text of a particular object and when I run it on Safari I am getting failure because of this reason :
TempTestSuite1566858141573.run(TempTestSuite1566858141573.groovy:35)
Caused by: com.kms.katalon.core.exception.StepFailedException: Actual text '
Free Shipping Over $50.00
' and expected text 'Free Shipping Over $50.00' of test object 'Object Repository/Shipping_Method_Page/US_Shipping/New/Free_Shipping_Over_50' are NOT matched.
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)
at com.kms.katalon.core.webui.keyword.builtin.VerifyElementTextKeyword$_verifyElementText_closure1.doCall(VerifyElementTextKeyword.groovy:57)
The same test case works fine when I run the test on Chrome or Firefox.
2019-08-26 22:42:16 - [TEST_STEP][PASSED] - verifyElementText(findTestObject("Shipping_Method_Page/US_Shipping/New/Free_Shipping_Over_50"), "Free Shipping Over $50.00"): Actual text and expected text of test object 'Object Repository/Shipping_Method_Page/US_Shipping/New/Free_Shipping_Over_50' are matched.
The HTML does have blank space before and after the text. Katalon seems to be auto truncating the blank spaces for Chrome and Firefox but not for Safari
How should I fix this issue, Should I add a trim() before and after the text or should I add an if statement which says if browser Safari then trim()
This is the approach I tried and is working. But I am not sure if this is the correct way
WebUI.verifyElementPresent(findTestObject('Shipping_Method_Page/CA_Shipping/New/Free_Shipping_Over_50'), 0)
Free_Shipping_Over_50_Text = WebUI.getAttribute(findTestObject('Shipping_Method_Page/CA_Shipping/New/Free_Shipping_Over_50'), 'textContent', FailureHandling.STOP_ON_FAILURE).trim()
System.out.println(Free_Shipping_Over_50_Text)
CustomKeywords.'kms.turing.katalon.plugins.assertj.StringAssert.equals'(Free_Shipping_Over_50_Text, 'Free Shipping Over $50.00', true, '', FailureHandling.STOP_ON_FAILURE)