Return Boolean result


#1

Hello!
I have one test case:
I have web registration webpage, there are field that i want to test, for example i have field name which can contain only letters i write example test:

 WebUI.openBrowser('http://demo.test.md/registrace')


WebUI.setText(findTestObject('Registration step_1/name'), 'qij1oei')
WebUI.click(findTestObject('Registration step_1/a_Odeslat'))
//'Get \'class\' attribute value of make appointment button'
attribute = WebUI.getAttribute(findTestObject('Registration step_1/name'), 'class')
//'Verify if \'class\' attribute value is correct for the button.'
booleon result = WebUI.verifyEqual(attribute, 'npt-1')
if (result == true ) {
	println ('ok')
}
else if (result == false) {
	println ('NOK')
}
WebUI.closeBrowser()

when everything is ok i have in HTMP class text = npt-1 when not ok class text = npt-1 error
when i have test case with good result everything works fine, but when i want to test with bad conditions i got the followint error:

2019-08-26 15:10:46.344 ERROR c.k.k.core.keyword.internal.KeywordMain  - ❌ Unable to verify equal between actual object 'npt-1 error' and expected object 'npt-1' (Root cause: com.kms.katalon.core.exception.StepFailedException: Actual object 'npt-1 error' and expected object 'npt-1' 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$_verifyEqual_closure1.call(VerifyEqualKeyword.groovy)
	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 Registration test 1 step.run(Registration test 1 step:26)
	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:337)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)
	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 TempTestCase1566821439509.run(TempTestCase1566821439509.groovy:21)

my question is how can i get only the boolean from this step

booleon classval = WebUI.verifyEqual(attribute, 'npt-1')

#2

Hello,
verify() function documentation is wrong and counter intuitive. Verify() return a boolean yes, but if it’s false, it also throw an exception and make the test fail. Since your object are differents, it will return false, throw an exception and fail the test.

Instead, I would suggest doing this :

 WebUI.openBrowser('http://demo.test.md/registrace')

WebUI.setText(findTestObject('Registration step_1/name'), 'qij1oei')
WebUI.click(findTestObject('Registration step_1/a_Odeslat'))
//'Get \'class\' attribute value of make appointment button'
attribute = WebUI.getAttribute(findTestObject('Registration step_1/name'), 'class')

if (attribute.equals('npt-1')) {
	println ('ok')
}
else  {
	println ('NOK')
}
WebUI.closeBrowser()

Let me know if it worked!


#3

WOW LoL =)))
It was pretty easy Thank you my friend!!!