Static Image Testing
Robot supports the testing of images loaded from the file system. This makes the tool eligible for 'offline' image testing, analysis and debugging, especially together with the Object Search image comparison algorithm.
Static image testing may be successfully applied in a number of scenarios:
- Testing of images, such as screen shots, photographs, maps, paintings and outputs of various image producing systems,
- Testing of systems updating an image file. Since the image client periodically checks the image file size and time stamp and reloads it whenever a change is detected, it may be used to test systems which generate output into an image file (or image files).
- Debugging of failed image comparisons from live desktop testing. If you modify your script to save the VNC desktop image to a PNG file whenever image comparison fails unexpectedly, for example using the Screenshot command, you may connect to the file later on and reapply the image comparison to find out what was wrong. As the static image behaves the same way as a live desktop, you may easily recreate the image template from the static image and verify the new functionality using the standard GUI tools.
Testing of images has a few specific aspects. Unlike live desktops, static images don't consume key events and the Press and Type/Typeline actions are disabled. If the image is truly static meaning that it is not being updated by an outside process, it also doesn't make sense to wait for an update event through the Waitfor command.
Static images are loaded through the Static Image Client. It is a component which behaves the same way as a live desktop client, such as the RFB/VNC one. Image files may be loaded in the Login dialog, through the CLI or by calling the Connect command with an argument in form of "file://<path_to_the_image>".
As an example let's consider a map-like image with black paths and green triangle objects:
Our goal is to find out the number and location of green triangles. This is a perfect task for the static image client combined with the object search algorithm. The script code as well as a video follows. You may optionally download the complete test suite and try it out on your own environment.
# Make the script look for template images in the same dir as the script Var _TEMPLATE_DIR="{_SCRIPT_DIR}" # Connect to the map image. Connect file://{_SCRIPT_DIR}/map.png # Locate all triangles and highlight them on the screen Compareto "{_SCRIPT_DIR}/triangle.png" method="object" passrate="85" rotations="40" color="01FF19" tolerance="100" draw="true" # Pause the script to allow to review the results. # Resuming will finish the script and clear up the drawings. # Should you need to work with the objects further on, their number # and coordinates are available through variables populated by the "object" method. Pause