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

**URL:** <https://forum.katalon.com/t/takescreenshot-can-a-timestamp-be-added-to-the-filename-to-make-it-unique/9547>\
**Category:** Web Testing\
**Tags:** web-testing, katalon-studio\
**Created:** [February 27, 2018, 3:14pm UTC](https://forum.katalon.com/t/takescreenshot-can-a-timestamp-be-added-to-the-filename-to-make-it-unique/9547 "2018-02-27T15:14:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Iain\_Finlayson](https://avatars.discourse-cdn.com/v4/letter/i/a88e57/32.png) [@Iain\_Finlayson](https://forum.katalon.com/u/Iain_Finlayson)\
**Post date:** [February 27, 2018, 3:14pm UTC](https://forum.katalon.com/t/takescreenshot-can-a-timestamp-be-added-to-the-filename-to-make-it-unique/9547/1 "2018-02-27T15:14:03Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![harini](https://avatars.discourse-cdn.com/v4/letter/h/8e8cbc/32.png) [@harini](https://forum.katalon.com/u/harini)\
**Post date:** [May 7, 2018, 6:30am UTC](https://forum.katalon.com/t/takescreenshot-can-a-timestamp-be-added-to-the-filename-to-make-it-unique/9547/2 "2018-05-07T06:30:58Z")

</div>

> [Iain Finlayson](https://forum.katalon.com/profile/4292/Iain%20Finlayson) 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?

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [May 7, 2018, 8:43am UTC](https://forum.katalon.com/t/takescreenshot-can-a-timestamp-be-added-to-the-filename-to-make-it-unique/9547/3 "2018-05-07T08:43:14Z")

</div>

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

```auto
 <ProjectName>\<TestSuiteName>\<TestSuiteInvokationTimestamp>\<TestCaseName>\<encoded URL string>.png

```

![](https://s3.amazonaws.com/katalon-forum/editor/e5/ae0puiz3xhnf.png "Image: https://s3.amazonaws.com/katalon-forum/editor/e5/ae0puiz3xhnf.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](https://s3.amazonaws.com/katalon-forum/editor/e5/ae0puiz3xhnf.png)

---

<div class="post-metadata">

**Author:** ![harini](https://avatars.discourse-cdn.com/v4/letter/h/8e8cbc/32.png) [@harini](https://forum.katalon.com/u/harini)\
**Post date:** [January 2, 2019, 1:27am UTC](https://forum.katalon.com/t/takescreenshot-can-a-timestamp-be-added-to-the-filename-to-make-it-unique/9547/4 "2019-01-02T01:27:01Z")

</div>

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’)
