Skip to main content

[WebUI] Take Element Screenshot

Description

Take a screenshot of a specific web element. The captured image will be saved in .png format.

Keyword name: takeElementScreenshot

Parameters

ParameterParameter TypeRequiredDescription
fileNameStringOptionalRepresents a path to the saved image. The path can be absolute path or relative path.
toTestObjectYesRepresents the element you want to take screenshot of.
flowControlFailureHandlingOptionalSpecify failure handling schema to determine whether the execution should be allowed to continue or stop.

Example

  1. You want to take a screenshot of an element that you have captured by using Katalon Spy Utility and stored in Test Object > UI > logo. The file name is logo.png and stored in the report folder. Default failure handling is used:
    import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
    import com.kms.katalon.core.configuration.RunConfiguration as RunConfiguration

    WebUI.takeElementScreenshot(RunConfiguration.getReportFolder() + '/logo.png', findTestObject('UI/logo'))
  2. You want to take a screenshot of a Test Object stored in a variable named header for TestOps Vision. Use the default file name:
    import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject

    // where ignoredElements is a user-defined List-typed variable.
    WebUI.takeElementScreenshot(header)
Was this page helpful?