50.5 The Image API
The Image API provides classes and interfaces to take screenshots, to save or load images or for own image comparisons. The image API is designed so that the different methods in general do not throw any exception. Instead, the different methods are logging warnings.
50.5.1 The ImageWrapper class
For taking screenshots you can use the Jython class ImageWrapper, located in the module
imagewrapper.py, which comes with the QF-Test
installation.
Here is a short sample Jython script demonstrating the usage of the Image API:
from imagewrapper import ImageWrapper
#create ImageWrapper instance
iw = ImageWrapper(rc)
#take screenshot of the whole screen
currentScreenshot = iw.grabScreenshot()
#save screenshot to a file
iw.savePng("/tmp/screenshot.png", currentScreenshot)
And the same in Groovy:
import de.qfs.ImageWrapper
def iw = new ImageWrapper(rc)
def currentScreenshot = iw.grabScreenshot()
iw.savePng("/tmp/screenshot.png", currentScreenshot)
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.