Add command trace and per command screenshots to Python test scripts

Last edited on

Python supports registering a function for profiling purposes. Using this mechanism it is possible to add command tracing and "per-command" screenshots to Python test scripts.

An example implementation (called "squish_trace") can be downloaded here .

Here is an example test script that makes use of the squish_trace functionality:

from squish_trace import *

def main():
    # Enable trace, 500 ms delay in between commands:
    squish_trace_enable(1000)

    # Enable trace, 500 ms delay in between commands,
    # enable screenshots, using saveDesktopScreenshot():
    #squish_trace_enable(command_delay_in_milliseconds=500, take_screenshots=True)

    # Enable trace, 500 ms delay in between commands,
    # enable screenshots, use external tool "take_screenshot"
    # for taking screenshots:
    #squish_trace_set_screenshot_external_command('take_screenshot "%s"')
    #squish_trace_enable(command_delay_in_milliseconds=500, take_screenshots=True)

    for i in range(3):
        test.log("Iteration #%s" % (i+1))
test.py

The additional log entries generated by squish_trace:

Note:

Related information and resources: