[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
Parameter | Parameter Type | Required | Description |
---|---|---|---|
fileName | String | Optional | Represents a path to the saved image. The path can be absolute path or relative path. |
to | TestObject | Yes | Represents the element you want to take screenshot of. |
flowControl | FailureHandling | Optional | Specify 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)