Connecting Katalon Studio into XLS and CSV files

Since reading from external source files has become an important part of how we get data, I wanted to put together some simple examples to show reading data from a CSV file, an XLS file and from a Database source. All three are very similar and since Katalon handles most of the work, it's easy to grab data from a file with just a few lines of code. We start by using the TestData library and reference the "Test Data File" from the "Data Files" object in the project. That is done with: TestData csvData = findTestData("Data Files/Data Source Name") Once we have that, we can use some of the built in Katalon keywords to get the number of rows in the file and the column names. int rowCount=csvData.getRowNumbers() List columnNamesList=csvData.getColumnNames() Once we have that information we know how many rows we can read and how many columns. We then use getValue to read our piece of information. temp1=csvData.getValue(columnName, rowNumber) […]

Programmatic Database query with Katalon

As mentioned previously, making dynamic database queries was a big goal for this year. Katalon makes this quite easy with a UI to set up the connection and a straightforward way of connecting to the data itself. To start the process, select Data Files, New Test Data and select Database as the source. Taking the configuration string from before, we connect to the database using this screen and provide the default query. This creates a default table of data that Katalon will work with when executing tests. Within our code, we use the TesData object to get at our database source. TestData inventoryDB = findTestData(‘Data Files/database object name’) We can now get the number of rows in the database, the names of the columns and read data from each column as needed. We need to reference each column with an index number rather than it’s name. Even though Katalon displays “item_number” as the column title, internally that is column 1. […]

Connecting Katalon to a Postgres Database

One of our goals for this year was to connect Katalon into our Postgres instance. It turned out to be quite simple, but we ran into a couple of errors before we got all the magic to happen. When using the standard connection string, we get an hba_conf error along with ssl=true errors. This can be fixed in the connection string by appending the two following parameters: sslfactory=org.postgresql.ssl.NonValidatingFactory ssl=true The connection string to be placed in Katalon looks like: jdbc:postgresql://hostname:5432/dbname?sslfactory=org.postgresql.ssl.NonValidatingFactory&ssl=true With this connection string in place, we were able to connect to the database without issue and execute queries.