takeScreenshot: Can a timestamp be added to the filename to make it unique

I know within Test Suite, you get a video recording of each of the iterations when I run the test cases from within Katalon Studio (console mode) and by Test Suite.

In Non-Console mode, I am told that no video recording is generated.

Therefore, if I want to capture a screenshot of the Login status of my AUT, I am using the ‘takeScreenshot’ command (See Below):

WebUI.takeScreenshot(‘C:/KAT_SS/Screenshot_EditLead/loginStatus.png’)

However when I iterate through, the ‘loginStatus.png’ gets over written. So is there a way to make the filename unique or add a timestamp?

1 Like

Iain Finlayson said:

I know within Test Suite, you get a video recording of each of the iterations when I run the test cases from within Katalon Studio (console mode) and by Test Suite.

In Non-Console mode, I am told that no video recording is generated.

Therefore, if I want to capture a screenshot of the Login status of my AUT, I am using the ‘takeScreenshot’ command (See Below):

WebUI.takeScreenshot(‘C:/KAT_SS/Screenshot_EditLead/loginStatus.png’)

However when I iterate through, the ‘loginStatus.png’ gets over written. So is there a way to make the filename unique or add a timestamp?

Were you able to find a solution for this?

Let me show you what I have done:

  1. make a folder “katalon-screenshots” where all of the subfolders and images are stored.
  2. make a subfolders and files with path of
 <ProjectName>\<TestSuiteName>\<TestSuiteInvokationTimestamp>\<TestCaseName>\<encoded URL string>.png

I have developed a set of custom keywords for myself to generate this path. It required fair amount of programming effort.

katalon-screenshots_directory.png

I used the below given code and it worked for me

Date today = new Date()

String todaysDate = today.format(‘MM_dd_yy’)

String nowTime = today.format(‘hh_mm_ss’)
WebUI.delay(3)

WebUI.takeScreenshot((((‘C:\Katalon Studio Test Evidence\Test -Wexpay\Screenshot\Admin\Download_template’ + todaysDate) +
‘_’) + nowTime) + ‘.png’)

1 Like