How to SAP GUI screenshot,so that it is attached in inbuilt katalon reports

Did you find any workaround for your need?

For time being I have created a robot which store the screenshot externally.

But still no way to get it in reports

We are able to interact with SAP session and perform transactions/verification using the VB script generated by SAP GUI in built recorder and JACOB

Could you share two things so we can dig into this?

  1. Your HTML report, so we can see what Window.takeScreenshot() is actually capturing.
  2. A short screen recording of the desktop recording failing, if you’re able to. It would also help to know the exact steps you’re running when it doesn’t work.

hi @arun.mohanty

you can get your robot screenshot into the built-in report. WebUI.takeScreenshot and Windows.takeScreenshot do not use any special api, they just write the png into the report folder and log a passed step with an “attachment” attribute pointing at the file. the html report picks that up and shows the thumbnail like a normal screenshot step. you can do the same from a custom keyword:

import java.awt.Rectangle
import java.awt.Robot
import java.awt.Toolkit
import javax.imageio.ImageIO
import com.kms.katalon.core.annotation.Keyword
import com.kms.katalon.core.constants.StringConstants
import com.kms.katalon.core.logging.KeywordLogger

class ReportShot {
    private static final KeywordLogger logger = KeywordLogger.getInstance(ReportShot)

    @Keyword
    static String capture(String name = 'sap') {
        File f = new File(logger.getLogFolderPath(), name + '_' + System.currentTimeMillis() + '.png')
        Rectangle screen = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize())
        ImageIO.write(new Robot().createScreenCapture(screen), 'png', f)
        logger.logPassed('screenshot ' + f.name, [(StringConstants.XML_LOG_ATTACHMENT_PROPERTY): f.name])
        return f.absolutePath
    }
}

then in the test case, right after your jacob transaction step:

CustomKeywords.'yourpackage.ReportShot.capture'('va01')

the file lands in the same Reports/… folder as the execution log, so it also travels with the report when you upload to true platform. someone used the same attribute with an absolute path for pdf reports here and it worked too: How to add images to the PDF report without using Katalon features - #3 by jhilario

two notes. it is internal api (KeywordLogger, StringConstants), so pin it in a custom keyword and retest after a studio upgrade. and java robot needs an unlocked interactive desktop, a locked screen or disconnected rdp gives you the black image you saw.