Screenshot not appear on report

Hi Katalon Team,
Kindly need your advice.

May I know why the screenshot does not appear on the report?
We successfully ran the test suite, and the capture was saved locally.

Thank You

2 Likes

Hi there,

Thank you very much for your topic. Please note that it may take a little while before a member of our community or from Katalon team responds to you.

Thanks!

Please make sure take screenshot option is checked under Project -->settings->Execution

Hi @atul.rai.
the option is already checked and the capture is saved locally.
but, not appear on report.

Okay, still i am unable to understand where (in the report) you are not getting screenshot.
Because i checked at my end , its showing.

We need to see which keyword you used to take the screenshot…
Could you please show your code?.

Hi @kazurayam and @atul.rai,

Below example report :
Screenshot 2024-04-30 204337

This is the code we used to take screenshots.

WebUI.takeFullPageScreenshot('C:/System and Internal Procedure/20. Katalon - Automate Testing Project/1. Login/2. After Login.png')

@cyntiaverolita

Do you want the PNG file to be stored in a local file you specified and at the same time attached into the Basic Report? ---- I did some experiments and found the system is NOT designed as you expect it to.

Please try changing your code as follows and run it:

WebUI.takeFullPageScreenshot()

The png will be included in the Basic Report if you specify NO local file path as argument to the keywork. If you specify the file path, the image will be saved in the location but is not attached into the report.

I also examined the following case:

WebUI.takeFullPageScreenshot(RunConfiguration.getReportFolder() + '/foo.png')

In this case, the foo.png was found attached into the Basic Report.

So, I was not correct in saying “the png will be included in the Basic Report if you specify NO local file path as argument to the keyword”. If you saved the png in the Reports directory with any file name, the Basic Report seems to be able to render the png.

I guess, the design of the program that compiles “Basic Report” matters. The reporting program seems to be assuming that the PNG files should be saved in the reports directory. If the PNG file is saved somewhere outside the assumed reports directory, then it can not include the PNG into the report html.

Well, I think this design is understandable; acceptable if properly documented.

However, it is a shame, the Basic Report has no official documentation. Therefore @cyntiaverolita was puzzled. @cyntiaverolita needs to find out how the system works by experiments as I did.

I read the source code of Katalon Studio and found my guess is right.

I hava Katalon Studio 9.0.0 installed on my Mac. In the folder

  • /Applications/Katalon Studio.app/Contents/Eclipse/configuration/resources/source/

I could find the source codes of classes that belong to the com.kms.katalon.core.** packages. In there, I coud find the Java source code of the class

  • com.kms.katalon.core.reporting.ReportUtil

This class compiles the so-called “Basic Report”. I could read the source through and found a Java code fragment that generates the HTML code fragment <img src="..."> which shows the attached screenshots.

  • com.kms.katalon.core.reporting.JsStepModel Line#172
    private void initLogRecords() {
        for (ILogRecord logRecord : stepLogEntity.getChildRecords()) {
            if (logRecord instanceof MessageLogRecord) {
                MessageLogRecord messageLog = (MessageLogRecord) logRecord;
                long logStartTime = messageLog.getStartTime();
                String logStatVal = messageLog.getStatus().getStatusValue().ordinal() + "";
                String logStatMsg = messageLog.getMessage();
                JsModel jsLogRecModel = new JsModel();
                jsLogRecModel.props.add(new JsModelProperty("startTime", logStartTime + "", null));
                jsLogRecModel.props.add(new JsModelProperty("status", logStatVal, null));
                jsLogRecModel.props.add(new JsModelProperty("message", logStatMsg, listStrings));
                // if (stepLogEntity.getAttachment() != null && !stepLogEntity.getAttachment().isEmpty()) {
                if (messageLog.getAttachment() != null && !messageLog.getAttachment().isEmpty()) {
                    File attachmentFile = new File(messageLog.getAttachment());
                    if (!attachmentFile.isAbsolute()) {
                        String logFolder = getLogFolder(messageLog);
                        if (logFolder != null) {
                            attachmentFile = new File(logFolder + File.separator + messageLog.getAttachment());
                        }
                    }
                    if (attachmentFile.exists()) {
                        try {
                            String md5 = encodeFileContent(attachmentFile);
                            jsLogRecModel.props
                                    .add(new JsModelProperty("link", "data:image/png;base64," + md5, listStrings));
                        } catch (Exception e) {
                            // TODO: Need some way to log errors here
                        }
                    }
                }
                logRecords.add(jsLogRecModel);
            }
        }
    }

This code fragment tells me that screenshot files found in the logFolder will be attached to the HTML report; otherwise won’t.

Hi @kazurayam,
Thank you for your explanation.

this issue happens randomly for several test suites, sometimes if we rerun the test suite, the screenshot appears on the report PDF.

I have no more idea. I’d quit posting to this.

@cyntiaverolita - I hope your issue has been resolved.

Adding the Katalon Studio team member to this thread to see if they have any insights @xuan.tran

Recently a new plugin “Extent Report Integration” was released,

This enables you to generate reports with screenshots attached in the way you like. I would recommend you to have a look at this plugin.

Hi All,

Thank You for your advice and support.
this issue already solved.

1 Like

For others’ references, could you describe what was your issue and how you resolved it?