TestSuiteContext#getTimestamp() is wanted

## Demo

I have made a demo project at GitHub - kazurayam/TestSuiteContext_getTimestamp_is_wanted
Please clone the project onto you PC and try running the test suite TS1.

## how to run the demo

- clone the project onto your PC

- open the project with Katalon studio

- load the test suite ‘TS1’

- execute the test suite with any browser you like

- in the project directory, you will find the `Results` directory is newly created.

- in the `Results` directory you find a PNG file.

then I got the Results directory and screenshot file as follows:

## What I wanted to achieve

With Katalon Studio I can easily start Web UI automated testing with WebDriver. With WebUI.takeScreenshot(path) I can easily take screenshots of target Web pages. But here I find an itchy problem: how to resolve the path of image files?

To tell conclusion first, I want to save screenshot files in the following location:

<project dir>/Results/<TestSuite name>/<TestSuite timestamp>/                              <TestCase name>/<encoded URL string>.png

for example:


In the demo project, I have implemented this approach with custom Groovy programming in TestListener, TestCase, and with GlobalVariables.

## How I implemented my idea

In the above screenshot, you would find a directory named `Results/TS1/20180611_140159`. This is made my custom Groovy scripts. Have a look at the TestListener. I wrote as follows:

// resolve the test suite timestamp.  e.g, '20180611_130937'

Here I got the timestamp from the current machine clock, and formatted the time value into a string of ‘20180611_140159’.

I felt comfortable enough with the screenshot file path:


If I repeatedly execute the Test Suite `TS1`, each TS1 execution will create an indivisual directory. Directories are differentiated by the timestamp value. Hence I can preserve multiple versions of screenshot images. This means, I can compare the current screenshot with other versions in an automated way. This idea makes me excited. The following article describes how to implement it with Image Magick.

## What this means

Provided that the screenshots files are stored in a well organized way, I can integrate Image Magick with Katalon Studio. Then Katalon Studio would newly equip a feature of local Visual Testing.

## A Problem found

You will find in the above screenshot a diretory named **./Reports/**TS1/20180611_140156. The Reports directory was created by Katalon Studio. Let’s compare the 2 timestamps:

- ./Reports/TS1/20180611_140156

- ./Results/TS1/20180611_140159

Ah, this is disappointing. No reason why these two should have different timestamp. I want to refer to the test suite timestamp managed by Katalon Studio runtime so that I make my directory with the same time stamp value.

## How to solve it

I want the `com.kms.katalon.core.context.TestSuiteContext` class to be added with a new method `getTimestamp()` or `getTimestampAsString()`. I would propose the following code snippet become possible:

class MyTestListener {
    def beforeTestSuite(TestSuiteContext testSuiteContext) {
            testSuiteContext.getTestSuiteTimestamp()   // I WANT THIS!



This means, I can compare the current screenshot with other versions in an automated way. This idea makes me excited.

Me too! Kudos, Kaz!


+1 from me too!

Some people want more information in the Katalon Studio’s Reports:

Let’ me think about generating my custom report in Katalon Studio.

If I am informed of the timestamp of a test suite run, I can locate the execution.properties and the execution0.log files in the /Reports// directory. Then I would develop a custom Groovy script which takes these 2 files as input, and generates my own custom report. I would be able to add any information I would like in my custom report referring to my own information sources. Also would be able to redirect my own report to any target I would like (for example, upload it into AWS S3 storage)

However there is a blocking problem. Current Katalon Studio does not provide any method by which we are informed of the current Test Suite timestamp. Without knowing the timestamp, I can not locate the report files of the current Test Suite run.

Again, I want the `com.kms.katalon.core.context.TestSuiteContext` class to be added with a new method `getTimestamp()` or `getTimestampAsString()`.




According to this description:

I can retrieve current generated reports location by the follwoing TestListener

import com.kms.katalon.core.annotation.BeforeTestSuite
import com.kms.katalon.core.context.TestSuiteContext
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.configuration.RunConfiguration
import java.nio.file.Path
import java.nio.file.Paths
class TL {
    def beforeTestSuite(TestSuiteContext testSuiteContext) {
        Path reportFolder = Paths.get(RunConfiguration.getReportFolder())

When I ran a Test Suite, I got the following output in the LogView:


Now I know I can extract the timestamp '20180618_165141 out of the report folder path.



thank you, its a great topic
help me a lot