Rename Screenshot

Hello everyone :slight_smile:

So, i have a question about the “TakeScreenshot” function in web testing.

Right now, if i use the TakeScreenshot keyword, the screenshot is store in:

username/git////Reports///TestSuite/Reportname/randomnumber.png

So, what i want, is to name the screenshot “SCREEN-1” but, store it in the “Reportname” folder. The “Reportname” folder has a timestamp name because it gets created, when the testsuite starts. So its a variable.

I tried:

WebUI.takeScreenshot(‘SCREEN-1.jpg’)

But then i get:

i/o error (java.io.FileNotFoundException: /Users/username/git////Reports//Testsuite/Reportname/SCREEN-1.jpg (No such file or directory)

and the SCREEN-1.jpg is stored in the Katalon main direction.

I also tried something like:

WebUI.takeScreenshot(‘/SCREEN-1.jpg’)
WebUI.takeScreenshot(‘/*SCREEN-1.jpg’)
WebUI.takeScreenshot(‘*SCREEN-1.jpg’)
WebUI.takeScreenshot(‘%SCREEN-1.jpg’)

but nothing is working the way i want it. So i basically have two questions right now:

Is there a way to just “rename” the screenshot in the standard report folder?
Is there a way to get the “Reportname” variable (TIMESTAMP) and use it to store the screenshot right there?

Thanks for your help :slight_smile:

Is there a way to just “rename” the screenshot in the standard report folder?

Yes, You can.
WebUI.takeScreenshot(‘mytest.png’)

More info here:
https://docs.katalon.com/katalon-studio/docs/webui-take-screenshot.html#example

Note:
Screen shot will be saved at root level if no path is provided.

Project location:
D:\automation

File will be saved at:
D:\automation

Is there a way to get the “Reportname” variable (TIMESTAMP) and use it to store the screenshot right there?

I dont think so it is. As folder is generated run time after the execution. Even if we achieve somehow, screenshot can’t be viewed if you open HTML summary report as image is of base64.

Hope it helps. Thanks

-Priyank