Creating a screenshot verification point (VP) usually consists of these steps:
- Bring the AUT into the desired state.
- Pick the desired object.
- In Application Objects view check the checkbox besides the object.
However, if the object is a volatile object, for example a menu, then picking it may be difficult or impossible, because it vanishes as soon as it loses input focus (for example to the Squish IDE that pops up again).
To resolve this one could apply the approaches described at Example – Creating screenshot verification points from test scripts and Article – Creating screenshot verification points for volatile objects (QMenu, QAction, Qt).
However, yet another approach (that does not involve executing an external application) is possible:
- Where the desired object is available in the test script, call a script function that creates a « dummy » screenshot VP for that object.
- Execute the test script – the screenshot VP should fail.
- Right click on the screenshot VP fail in the Test Results view and select Use As Expected Result.
(Then run the test script again to verify that the screenshot VP passes.)
Here is a test script with a function that creates a screenshot VP file for a specified function:
import sys def main(: startApplication("addressbook") activateItem(waitForObjectItem(":Address Book_QMenuBar", "File")) # Disable this after the first execution: screenshot_vp_dummy(":Address Book.File_QMenu", "VP6") # Accept failed image as master after first execution: test.vp("VP6") activateItem(waitForObjectItem(":Address Book.File_QMenu", "New")) ... def screenshot_vp_dummy(object_name, vp_file_name): fn1 = squishinfo.testCase + "/verificationPoints/%s" % vp_file_name if os.path.exists(fn1): test.fatal("VP file already exists: %s" % fn1) sys.exit() fn2 = squishinfo.testCase + "/verificationPoints2" if not os.path.exists(fn2): os.mkdir(fn) s = """<?xml version="1.0" encoding="UTF-8" standalone="no"?> <VerificationPoint type="Screenshot" version="4"> <Description/> <Verification object="%s" type="PNG">iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAMSURBVBhXY/j//z8ABf4C/qc1gYQAAAAASUVORK5CYII=<Mask/> </Verification> </VerificationPoint>""" f = codecs.open(fn1, "w", "utf8") f.write(s % object_name) f.close()