Screenshot Verification Points for Menus & other volatile Objects

Screenshot Verification Points for Menus & other volatile Objects

Creating a screenshot verification point (VP) usually consists of these steps:

  1. Bring the AUT into the desired state.
  2. Pick the desired object.
  3. 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

  1. Where the desired object is available in the test script, call a script function that creates a “dummy” screenshot VP for that object.
  2. Execute the test script – the screenshot VP should fail.
  3. 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():
    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:
    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)
    fn2 = squishinfo.testCase + "/verificationPoints2"
    if not os.path.exists(fn2):
    s = """<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<VerificationPoint type="Screenshot" version="4">
    f =, "w", "utf8")
    f.write(s % object_name)
Clemens Anhuth started out using Squish as a user and then joined froglogic in 2009. Working mainly as a Technical Support Engineer, Clemens also oversees the technical support department in general.


Leave a reply

Your email address will not be published. Required fields are marked *