[Mobile] Take Area Screenshot
Description
Take a screenshot of a UI element to send to TestOps Vision. The test engine will scroll to this element first then taking a screenshot.
Keyword name: Mobile.takeElementScrenshot
Parameters
Parameter | Parameter Type | Required | Description |
---|---|---|---|
fileName | String | Optional | Absolute path to the stored image file. fileName should contain '.png' as images are stored to the '.png' format. If the file name is not defined, the test engine will generate a random file name. |
rect | Rectangle | Yes | A rectangle defining the position and size of the area to be captured. |
ignoredElements | List | Optional | List of the ignored elements. These elements will be hidden by drawing an overlap color layer. If the test engine failed to hide the element by any problems, this keyword would continue without impacting the result. |
hidingColor | Color | Optional | The color used to draw the overlap layer. If not defined, Color.GRAY is used. |
flowControl | FailureHandling | Optional | Specify failure handling schema to determine whether the execution should be allowed to continue or stop. |
Returns
A String representing the path to the captured image. Throws StepFailedException
if the defined rectangle is outside the application viewport or Katalon Studio can't store the image in the disk.
Example
You want to capture a custom rectangular region of the mobile screen (from the top-left corner with dimensions 1000×1500):
// add import libs first
import org.openqa.selenium.Rectangle as Rectangle
import com.kms.katalon.core.configuration.RunConfiguration as RunConfiguration
// take sreenshot of an area start at (x: 0 , y: 0) with size (height: 1500, width: 1000) and store to report folder
Mobile.takeAreaScreenshot(RunConfiguration.getReportFolder() + '/area_screenshot.png', new Rectangle(0, 0, 1500, 1000), [findTestObject('hide_element_1'), findTestObject('hide_element_2')], Color.BLUE)