Katalon Recorder - Validating Basket Subtotal

923 Views Asked by At

I am using Katalon Recorder to automate some website tests. One is to check that basket subtotal is calculated correctly. I can replay the test all the way to the check-out stage and here I can check that the values are correct by actually looking at them. I can even highlight the value and see that it has element ID. But how do I write a test so that if that value is not, say, £999.99 - the test fails? Do I need Katalon Studio for this?

Basket value that I want to validate automatically

P.S. I have no experience with coding, so apologies for using layman's terms.

2

There are 2 best solutions below

6
On BEST ANSWER

My suggestion is, after you recorded the test, use the recording as a starting point, not as a complete piece of work.

You need to verify text inside of an element, right? So, add a few lines to your test:

String elementText = WebUI.getAttribute(findTestObject('path to object in OR'), 'value')
WebUI.verifyMatch(elementText, '£999.99', false)
0
On

With a help of a colleague (not claiming any credit for this!), I worked out how to validate a value of an element on a page using the "assertText" command.

1) Hit "Record"

2) On the page you are testing, find the text that needs validating

3) Click on it

4) Stop recording

5) Now click on the command you just recorded and change command from "click" to "assertText"

6) Ideally, the target should already be selected correctly, but if you want to make doubly sure, select the element using the button to the right from the "Target" field

7) In the "Value" field, type in the expected value (make sure you include all the symbols, like in my case the value should be"£999.99" not "999.99" or the test fails)

8) Run the test

9) I advise changing the value to something else just to make sure the test fails if the values do not match, then changing it back again

10) Save the test. Voila!