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

Note:

From version 7.7.0, this keyword is available.

Parameters

ParameterParameter TypeRequiredDescription
fileNameStringOptionalRepresents a path to the saved image. The path can be absolute path or relative path.
toTestObjectOptionalRepresents 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

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'))
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?