Download PDF version - QF-Test
Transcript
37.8.
Image API
643
import de.qfs.ImageWrapper
def iw = new ImageWrapper()
def currentScreenshot = iw.grabScreenshot()
iw.savePng("/tmp/screenshot.png", currentScreenshot)
Example 37.3: Image API in Groovy
Following is a list of the methods of the ImageWrapper class in alphabetical order. The
syntax used is a bit of a mixture of Java and Python. Python doesn’t support static
typing, but the parameters are passed on to Java, so they must be of the correct type to
avoid triggering exceptions. If a parameter is followed by an ’=’ character and a value,
that value is the default and the parameter is optional.
ImageWrapper ImageWrapper(RunContext rc)
Constructor method of the ImageWrapper class.
Parameters
rc
The current run context of QF-Test.
ImageRep grabScreenshot(int x=None, int y=None, int width=None,
int height=None)
Take screenshot of the whole screen. If you use the parameters x, y, width and height,
you can take a screenshot of a specific region of the screen.
Parameters
x
The X coordinate of the left upper corner of the region to
take the screenshot.
y
The Y coordinate of the left upper corner of the region to
take the screenshot.
width
The width of the region to take the screenshot.
height
The height of the region to take the screenshot.
Returns
An ImageRep object containing the actual screenshot.