The LEAP

Automation insights and productivity tips from LEAPWORK.

All Posts

Automating Stopwatches for Timing Tests and Processes

Measuring elapsed time can be a key component in test automation. For instance, a business requirement may state that a search query must not take more than 5 seconds to respond with results. Although there are dedicated performance testing and monitoring tools such as dynaTrace on the market which can provide detailed insights, LEAPWORK can easily be used to do sanity checks on business transactions using the Stopwatch building block.

The following demonstrates how a single Stopwatch is started through its green execution input connector and the elapsed time is then written to the run log after some time is spent waiting:

Stopwatch demo 1

Stopwatches reset every time their green execution input connector is triggered. This will for instance log approximately 5 seconds to the log endlessly until the case is manually stopped (for instance with the keyboard shortcut F10):

Using stopwatches demo

The Stopwatch block can be used in many different scenarios. Here's an example that reads search terms from an Excel sheet and then types them into the search box on ebay.com and checks that the results are never shown more than 5 seconds later:

Using stopwatches on ebay

The Stopwatch is started as soon as the search term is entered and the elapsed time is checked as soon as the "results" are found on screen. A Set date/time block is used to specify exactly 5 seconds as the comparison value.

It's worth noting that even though LEAPWORK isn't well suited for very precise performance testing, by using the fast image recognition algorithms in eg. a Find image block, only a few hundred milliseconds might be "lost" between the different steps in the test case and so the results are at the very least a good starting point for further investigations.

The "Elapsed time" property of the Stopwatch block can be expanded to reveal individual hour, minute, second and millisecond counters. But there's another use for the total "Elapsed time" property that can be useful. When compared in a Compare block using the comparison type "Number", the value is automatically converted to the total number of seconds with milliseconds as decimals. So for instance, 00:01:05:231 (one minute, five seconds and 231 milliseconds) will be understood as the value 65.231.

This can simplify the test case by removing the need for the Set date/time block. In the example below, 3 seconds are used as the comparison value B:

Using stopwatches to find results

For another example of how to use Stopwatches in LEAPWORK, see this Learning Center video.

Claus Topholt
Claus Topholt
CTO and co-founder of LEAPWORK.

Related Posts

LEAPWORK vs. Selenium Web Automation

Selenium WebDriver is great for automating browsers, but as a stand-alone automation tool it has some limitations. This post compares script-based Selenium automation with LEAPWORK web automation.

Reduce Maintenance Workload 97% with Context-Driven Test Automation

IT projects are multidimensional and difficult to perceive. How do you test a project with potentially infinite dimensions?

Prove Your Skills with a Test Automation Certification

When a company decides to adopt new methods or change existing processes, for example by rolling out new software, it often requires that employees upgrade their skill set or learn completely new skills. One way to ensure that an employee has the required skills is to rely on certification. The same goes for consultants who need to document that they are proficient in the tasks they are hired to do.