Comment puis-je faire des captures d'écran de mon application client avec QF-Test ?

QF-Test only provides on-board means to write screenshots of a client application to the test-run log. This can be done via the “Message” node or the procedure qfs.run-log.screenshots.logScreenshot from the qfs.qft standard library.

Save screenshots to a file

Sometimes you don’t want to store a screenshot in the test-run log but use it for other things and store it in a directory first. This is of course also possible with QF-Test, but it requires a script - but just a very small one:

from imagewrapper import ImageWrapper
from java.io import File
screenshot = ImageWrapper(rc).grabImage(rc.getComponent(#Window:”))
screenshot.writeToFile(File(str(rc.groups.qftest.suite.dir) + /screenshot.png))

This Jython SUT script uses the exact same mechanism to create screenshots that is used for the test run log.

rc.groups.qftest.suite.dir is a useful shortcut to get the directory of the current test suite. You can of course also call writeToFile() with any other path. “#Window:” is a SmartID and stands for the first window of your application. You can also specify a more specific component here to take a screenshot of a specific part of the application UI.

You can read more about the ImageWrapper class in the QF-Test manual: The ImageWrapper class.