Is there any way to take screenshot for every step and appending it in Report?

By default in execution report only for failed steps the screenshot is getting captured, but I want to capture screenshot for every steps in report not separately. So is there any way?

I have tried to take the screenshot separately by ‘WebUI.takeScreenshot()’ it’s working fine for me. But in this case how to append the captured screenshot in report?

Hi Sudhir,

Did you use the parameters of the WebUI.takeScreenshot()?

In my case, I did that approach too. Taking screenshots of important steps.

What I did was refer to my code below:

//in this case it will be saved in your Reports folder
WebUI.takeScreenshot(String.format(‘Reports/%1$s_%2$s.png’, fileName1, fileName2)

Hope that helps. . . :slight_smile:

Hey Arnel,

Your code is only for saving the screenshot inside Report folder, but my requirement is how to get or embed the screenshot in execution report, just like screenshot is showing for failed steps?

… how to get or embed the screenshot in execution report, just like screenshot is showing for failed steps?

I don’t think such feature is supported by Katalon Studio.

If you want a report which has all screenshots you took by WebUI.takeScreenshot() keyword, you need to make a repository of image files and compile a custom report for your self.

2 Likes

Hi Sudhir,

You mean saving the screenshot into the results/reports folder? (e.g. Reports\TestSuiteName\2018_221835) together with the fail results if there’s any?

1 Like

I agree with Kazurayam, reports folder are auto generated by katalon once you run your suite or test suite collection. It’s quite impossible since the results folder being generated corresponds to time and date meaning every run of test suite it generates a new results folder. So it will be hard for you to save your programmatically taken screenshots to the results folder you prefer. What I stated earlier is the nearest location where you can save your screenshots.

1 Like

In fact I have just the same need. I want to take many screenshots (regardless test case fails or not), want to download many files (PDF, Excel, Json etc) from my web site, while saving files locally. And I want to make index.html with which I can retrieve the saved files (Materials I would call). The index should also contain the summary of test results (failure/success) plus links to the detail Report generated by Katalon Studio.

I have been working for the last couple of months implementing an additive to Katalon Studio which supports the following:

(1) create a new directory called “Materials” under the Katalon project directory (beside the Reports directory). In the Materials tree, all the screenshot image files and other files created during test case run (for example, downloaded PDF or Excel files) in a well organized directorory tree such as

<project>/Materials/TestSuiteName/yyyyMMdd_hhmmss/TestCaseName/encodedURIstring.png

(2) creates /Materials/index.html. It look like the following screenshot shows. In there all the files in the “Materials” directory is listed. I can retrieve all the materials by clicking links.

(3) I want to keep the Materials in a time-series manner. I want to keep screenshot files taken previously. Provided with the previous screenshots kept in hand, then I would be able to compare 2 screenshots of a single web page, taken previously and now, using some tools such as Imagemagick or AShot. With this feature become available, I would get a primitive ‘Visual Testing’ feature within Katalon Studio.
This feature would be useful for me to do Regression testing by comparing many pages of 2 environments — Product and Development. I want to check if the 2 environements looks similar or not. My new magical “Materials” feature would enable me to do the regression testing automated.

I have done 90% of the development, but not yet reached to ver 1.0. I am willing to share my artifact to all of Katalon Studio users on GitHub sometimes in this August.

スクリーンショット 2018-08-01 23.18.18.png

2 Likes

Great work ! kazurayam. I am your follower here.i raised mobile browser question is helping please help if you can.wants to knowhoetptest on real mobile device browser using katalon studio thanks

kazurayam said:

In fact I have just the same need. I want to take many screenshots and download many files (PDF, Excel, Json etc) from my web site while saving them locally. And I want to make index.html with which I can retrieve the saved files (Materials I would call). The index should also contain the summary of test results (failure/success) plus links to the detail Report generated by Katalon Studio.

I have been working for the last couple of months implementing an additive to Katalon Studio which supports the following:

(1) create a new directory called “Materials” under the Katalon project directory (beside the Reports directory). In the Materials tree, all the screenshot image files and other files created during test case run (for example, downloaded PDF or Excel files) in a well organized directorory tree such as

<project>/Materials/TestSuiteName/yyyyMMdd_hhmmss/TestCaseName/encodedURIstring.png

(2) creates /Materials/index.html. It look like the following screenshot shows. In there all the files in the “Materials” directory is listed. I can retrieve all the materials by clicking links.

(3) I want to keep the Materials in a time-series manner. I want to keep screenshot files taken previously. Provided with the previous screenshots kept in hand, then I would be able to compare 2 screenshots of a single web page, taken previously and now, using Imagemagick utility. With this feature become available, I would get a primitive ‘Visual Testing’ feature within Katalon Studio.

My work has been done 90%. Not reached to ver1.0 yet. I am willing to share my artifact to all of Katalon Studio users on GitHub sometimes in this August.

Hey kazurayam,

First of all thanks for your valuable response.

I think your idea can solve my problem. I have one doubt here how to make the index.html file which will link to all the taken screenshots and test summary?

When you take a screenshot using WebUI.takeScreenshot(filepath), you need to specify where to save the image. How do you resolve the location of the screenshot files? Katalon Studio provides a way to take screenshot but it does not support locating the files created during a test case run. Here I find a feature to be developed.

My idea is to save an image in the following location:

<project>/Materials/TestSuiteName/yyyyMMdd_hhmmss/TestCaseName/encodedURIstring.png

This location should be resolved by algorithm because I can not hard-code the path manually everytime I run test cases. Therefore I have developed a Groovy Library which resolves the file path to save screenshots.

Just to give you an idea, here I copy&pasted an example test case which makes use of my new magic:

import static com.kms.katalon.core.testobject.ObjectRepository.findTestObjectimport java.nio.file.Pathimport com.kazurayam.material.MaterialRepositoryimport com.kms.katalon.core.model.FailureHandling as FailureHandlingimport com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUIimport internal.GlobalVariable as GlobalVariable/** * Take a screenshot of a Web page, save PNG file to make it a Material */WebUI.openBrowser('')WebUI.navigateToUrl('http://demoaut.katalon.com/')WebUI.maximizeWindow()WebUI.verifyElementPresent(findTestObject('Page_CURA Healthcare Service/a_Make Appointment'),	10, FailureHandling.STOP_ON_FAILURE)MaterialRepository mr = (MaterialRepository)GlobalVariable.MATERIAL_REPOSITORYassert mr != nullPath pngFile = mr.resolveScreenshotMaterialPath(GlobalVariable.CURRENT_TESTCASE_ID, WebUI.getUrl())WebUI.takeScreenshot(pngFile.toString())WebUI.comment("saved a screenshot into ${pngFile.toString()}")Path pngFileOnceMore = mr.resolveScreenshotMaterialPath(GlobalVariable.CURRENT_TESTCASE_ID, WebUI.getUrl())WebUI.takeScreenshot(pngFileOnceMore.toString())WebUI.comment("saved a screenshot into ${pngFileOnceMore.toString()}")WebUI.closeBrowser()

Provided with the instance of com.kazurayam.material.MaterialRepository, all of the PNG files are stored in a pre-designed location. The class implements a set of methods to traverse the contents. Using the traversal methods, an Indexer class generates the index.html.

---------------------------------------

Concerning your question

how to make the index.html file which will link to … test summary?

I know that the test result info is stored here:

/Reports/TestSuiteName/yyyyMMdd_hhmmss/JUnit_Report.xml

I know where I can find the information, so my index.html can easily refer to the test summary.

2 Likes

Guys,

I just have written a post about my “Visual Testing” solution in Katalon Studio:

Please have a look.