Updated February 1st 2017.
The Stopwatch building block is used to measure elapsed time between various parts of a test case.
This can for instance be used to measure how long it takes for an application to fully open or for a business transaction to complete. In combination with a Compare block, it can for instance be used to assert that something must complete within a specific time-frame.
Another example can be found in the Use the clipboard to insert text lesson, where the time it takes to insert text using different methods is measured using the Stopwatch block.
Fully expanded, the block shows the following properties:
The Block Header (“Stopwatch”)
The green input connector in the header is used to trigger the block to start executing and thereby starting or resetting the stopwatch.
The green output connector in the header triggers once the stopwatch has been started (or reset).
The title of the block (“Stopwatch”) can be changed by double-clicking on it and typing in a new title.
The Elapsed time property contains a “timespan” of the total elapsed time from when the stopwatch’s green input connector was last executed, for instance 00:01:05:0004123 (1 minute, 5 seconds and 0,4123 milliseconds).
The property can be expanded to reveal individual sub-properties for hour, minute, second and millisecond.
The following is an example of an endlessly looping test case that resets a stopwatch every 65 seconds, outputting the total elapsed time as well as the current elapsed seconds and milliseconds.
In the example, for each iteration, Field 1 will contain a timespan value of something like 00:01:05:0004123, while Field 2 will contain 5 and Field 3 will contain something like 0,4123.
When used as a number, for instance in a Calculate block, timespans are converted as the total number of seconds and milliseconds. In this example, that would be 65,0004123.
Examples of usage: