How to set date today in email summary?

Good Day,

I have a problem that I want my summary to be (see below) after test execution is done.
“{Date Today} - Summary Report”

Here’s my setting

Profile
image

Does anyone know what is the correct script to define in the Profile to get the date now?

Thanks

I’m not sure about setting the date in the Profile, however, you could try to set your date (as String) like:

new Date().format("M/d/yyyy")

And you can definitely do it within your “@SetUp” or even within your test case.

Date todaysDate = new Date();
GlobalVariable.dateToday = todaysDate.format("M/d/yyyy");

or

Date todaysDate = new Date();
GlobalVariable.dateToday = todaysDate.format("MMM d, yyyy");

or

import java.text.SimpleDateFormat

SimpleDateFormat sdf = new SimpleDateFormat("M/d/yyyy");
Calendar cal = Calendar.getInstance();
cal.setTime(new Date()); //Use today’s date
GlobalVariable.dateToday = "${sdf.format(cal.getTime())}";
1 Like

https://docs.katalon.com/katalon-studio/docs/execution-settings.html#support-global-variables-in-email-settings

From version 7.7.0 onwards, you can customize Email Settings with Global Variables and override their default values via the Command line.

It would nice if the document covers this case as an example.

I think there’s no solution for this now.
I will use testOps for the moment.

Thanks for you help

@Brylesu

I am one user of Katalon. I guess that you want to put the current executing time in the title of email. I think that: by using Global Variable, after executing test suite completely, the value will be reset, not storing value during running time. I found a way to work around for this case

  1. Define your Global Variable

  2. Generate date time

Windows: date /t

MacOS: date ‘+%Y/%m/%d %H:%M:%S’’

  1. After step#2, you have value about the that time. Next step is to read the batch file via this link Batch Script - Functions (tutorialspoint.com)

  2. After getting the way to write batch file, you can write your batch file to execute

4.1 Create batch file with step to get current date (see step#2)
4.2 Store value returned in 4.1 into another variable of batch file
4.3 Override value in the command of Katalon

katalonc -noSplash -runMode=console -projectPath=“Your Project.prj” -retry=0 -testSuitePath=“” -browserType=“Chrome” -executionProfile=“default” -apiKey=“your key” -g_myDate=<value in step 4.2>

More details about this override can be found here: https://docs.katalon.com/katalon-studio/docs/execution-profile-v54.html#update-global-variables-during-runtime

  1. Execute the command and check your email

From my side, I override the value with “aaaaa”, I see it works from my side, you can override value with your date

And here is result:

Original settings: Blank value

After override:

Hope it is useful.

FYI

Thanks Man!

@Brylesu

Create reusable function that returns date & time in a desired format, you want.

In my case my case, I created a function named browser.DateFn.formatDateTime() assign it to Global Variable as shown in the below image - Script view.

The report email displays the date as highlighted in yellow.

image

2 Likes