Show the currently executing Test Case both before and after it runs

After putting dozens of Test Cases together, I wanted a way to show where one test ended and another began. That way if something failed, I would at least have an idea which Test Case needed debugging or what sort of data was being read that caused the error. This lead me to add a log.logWarning() command at the start and end of every test case. While this is fine, and works, there is a better way to handle it that requires less user intervention and it’s all but built in to Katalon. The process is to use a Test Listener. This allows code to be executed at the start and end of every Test Case. In my simple example, the name and the status of the test are written to the log file during execution. To make the Test Listener, right-click on Test Listener within Katalon Studio and select the options for Before and After a Test Case. Within […]

Sorting in Ascending and Descending order with .toStorted() and .reverse()

Until now my validation of sorted objects has been quite minimal. I’ve gotten by with very simple tests such as IF A>B, IF B>C. However, there is a much better and simpler way to check sorting using the Groovy functions of .toSorted(). numberList=numberList.toSorted() To make proper use of this, I would read values from a table into a my own List. I would then duplicate that List, sort it, then compare if the two were a match to each other. However, .toSorted() returns a list in Ascending order. While this is extremely handy, how do you get the List in Descending order? A second command, .reverse() can be used to quite literally, reverse the list. Since the list is already sorted Ascending, the reverse of that would be Descending. numberList=numberList.reverse() In combination with a sorted list it’s not uncommon to need to remove duplicates. The .toUnique() command does just that. The sort of the List is maintained with the duplicate […]

Checking to see if search results contain the search criteria

One of the tests I’ve been working on is to search for a particular record, then confirm the results contain the search criteria. For example, if I enter the word, “limited” as the name for a company in my search, each record returned needs to contain the word, “limited” in the title. It turns out to be quite simple using the “.contains” syntax of Groovy. Quite literally, see if the text contains the string you’re looking for. To make my example more robust, all the text is converted to lower case so there’s no confusion between “limited” and “Limited”. After entering the search criteria, the results are read from a table. The text is read into a variable, converted to lowercase and checked to see if it contains the result. The evaluation can be done in a single line and looks like: //Convert the name and search criteria to lowercase to make sure they match tempResult=recordName.toLowerCase().contains(searchCriteria.toLowerCase()) For this example, “searchCriteria” […]

Passing multiple variables to an object in Katalon Studio

With the success of our first automation project, work has begun on automating another site. Based on the techniques already learned, solutions are being code a lot quicker than the first time around. One of the new methods to employ for this project is to create multi-parameter objects. For the first project there were lots of individual objects defined to retrieve specific pieces of information. This worked just fine, but it made for a lot of objects and a lot of maintenance. The goal this time is to try and slim that down. The most common multi-parameter object is for a table where the row and column can be passed. The object definition should look familiar and is represented by: //div[@id=’table’]/table/tbody/tr[${row}]/td[${column}] To read a cell from the table, the row and column can be passed as numbers, such as: tempText = WebUI.getText(findTestObject(‘table-DataTable’, [(‘row’) : 1, (‘column’) : 3])) To read the entire table, variables are passed in a set of […]