Web.takeScreenshot saving files concerns/improvements

Hi,

I can take a screenshot and save it in a specific location but I would like this files to be saved in the Report folder when test is executed as a part of the test suite. How can I do that?

Also, screenshots should be included in the HTML report. (currently it just says “Passed Talking screenshot successfully”

I can see that only in case of a failure screenshot is included in the report but I would like my screenshots to be included there as well.

Thanks,
Rasko

Hi Rasko,

I can take a screenshot and save it to a specific location but I would like this files to be saved in the Report folder when the test is executed as a part of the test suite. How can I do that?

When you use keyword takeScreenshot, Katalon Studio will automatically take the screenshot and save to Report folder respectively. Simply add this keyword to the preferred test case in any Test Suite.

Also, screenshots should be included in the HTML report. (currently, it just says “Passed Talking screenshot successfully”

We did run a couple sample tests with the takeScreenshot keyword, and the screenshots were included in Test Suite execution Reports. We used Katalon Studio V5.2. Please double check to see if Katalon Studio app is up to date.

Let us know if you still have any problems.

Cheers,
Liam

Ok. It works but it is confusing that if I want to name the attachment it will not go into the report folder and it would not be included into report. That is why I assumed that functionality is not working as intended.

In my opinion, we should be able to name attachments.
Thanks!
Rasko

Hello @“Rasko Pjesivac”, in your case, I think we can do as below:

//Get execution source
String excutionSource = RunConfiguration.getExecutionSource()
//Get Log folder path if run in Test Suite level:  
String logFolderPath = RunConfiguration.getLogFolderPath()
//Get project path: 
String userDir = System.getProperty("user.dir")
//if execution source is test suite, execute the takeScreenshot which will be saved in log folder path
if(excutionSource.contains(userDir+"\\Test Suites") ){
WebUI.takeScreenshot(logFolderPath +'\\'+  "your_attachment_name.extension")
WebUI.takeScreenshot()
} //else: execution the takeScreenshot which will be saved in your identified directory
else{
WebUI.takeScreenshot("D:\\testScreenshot" + "your_attachment_name.extension")
}

Hello,
Rasko is actually right, when we specify the filename , for example : WebUI.takeScreenshot(‘My_file_name’.png)
The screenshot is not saved in the Test suite Execution Report Folder.

Proof that this is not an intended behavior : on Katalon Studio, when I go in my Test case log to find the screenshot, and I click on the “attachment” icon, I get the error "FileNotFoundException:c:\users\username\Reports\TestSuiteName\20180115_10530\My_file_name.png (file could not be found)"

For the second Point of Rasko, he suggested that the HTML reports include hypelinks to the screenshot folders for easier analysis, which is not the case today.

Dimitry SIRISAKD said:

Hello,
Rasko is actually right, when we specify the filename , for example : WebUI.takeScreenshot(‘My_file_name’.png)
The screenshot is not saved in the Test suite Execution Report Folder.

Proof that this is not an intended behavior : on Katalon Studio, when I go in my Test case log to find the screenshot, and I click on the “attachment” icon, I get the error "FileNotFoundException:c:\users\username\Reports\TestSuiteName\20180115_10530\My_file_name.png (file could not be found)"

You need to pass in the FULL path, e.g: WebUI.takeScreenshot(‘E:\\My_file_name.png’). Without its full path then the report will not be able to find it and display it in the report.