Compare data in 2 test objects and Verify Less Than

I am trying to compare data in 2 fields and then verify if the number (153.08) in one field is less than the number in another field (236.98)

I can get the attribute of the two fields with the following code and it does print the two totals. Then I am trying to use VerifyLessThan and setting the test objects, but this isn’t working.

value = WebUI.getAttribute(findTestObject(‘Audit/Page_/AT_Billed_Total’), ‘value’)

println('The value is: ’ + value)

value = WebUI.getAttribute(findTestObject(‘Audit/Page_/AT_Audit_Total’), ‘value’)

println('The value is: ’ + value)

WebUI.verifyLessThan(findTestObject(‘Audit/Page_/AT_Audit_Total’), findTestObject(‘Audit/Page_/AT_Billed_Total’))

2020-01-17 13:36:23.664 DEBUG testcase.GL01 - Import GL Code - 87: value = getAttribute(findTestObject(“Audit/Page_/AT_Billed_Total”), “value”)
2020-01-17 13:36:23.933 DEBUG testcase.GL01 - Import GL Code - 88: println("The value is: " + value)
The value is: 236.98
2020-01-17 13:36:23.935 DEBUG testcase.GL01 - Import GL Code - 89: value = getAttribute(findTestObject(“Audit/Page_/AT_Audit_Total”), “value”)
2020-01-17 13:36:24.224 DEBUG testcase.GL01 - Import GL Code - 90: println("The value is: " + value)
The value is: 153.08
2020-01-17 13:36:24.225 DEBUG testcase.GL01 - Import GL Code - 91: verifyLessThan(findTestObject(“Audit/Page_/AT_Audit_Total”), findTestObject(“Audit/Page_/AT_Billed_Total”))
2020-01-17 13:36:24.292 ERROR c.k.k.core.keyword.internal.KeywordMain - :x: Unable to verify actual number ‘TestObject - ‘Object Repository/Audit/Page_/AT_Audit_Total’’ less than expected number ‘TestObject - ‘Object Repository/Audit/Page_/AT_Billed_Total’’ (Root cause: java.lang.IllegalArgumentException: Actual number with value ‘TestObject - ‘Object Repository/Audit/Page_/AT_Audit_Total’’ is not a valid number
at com.kms.katalon.core.helper.KeywordHelper.comparingNumberObject(

I figured this out quicker than I thought. I had to compare the two objects as variables instead of test objects. Code I used is:

ATBilledTotal = WebUI.getAttribute(findTestObject(‘Audit/Page_/AT_Billed_Total’), ‘value’)

println('The value is: ’ + ATBilledTotal)

ATAuditTotal = WebUI.getAttribute(findTestObject(‘Audit/Page_/AT_Audit_Total’), ‘value’)

println('The value is: ’ + ATAuditTotal)

WebUI.verifyLessThan(ATAuditTotal, ATBilledTotal)

Not quite.

What you’re actually doing when you do this…

ATBilledTotal = WebUI.getAttribute(findTestObject(‘Audit/Page_/AT_Billed_Total’), ‘value’)

is retrieving the value stored in the web page element represented by the specified Test Object. Which is exactly what your original post was asking about (sorry, I didn’t see it earlier!)

I’ll mark your solution as The Solution :slight_smile: