Book demo
Start trial
Book demo
Start trial

The LEAP

Automation insights and productivity tips from LEAPWORK.

All Posts

Automated Performance Testing: Using Stopwatches in Test Automation

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.

Everything you need for codeless test automation

Learn more about codeless test automation in our guide to reducing risk, lowering costs, and driving value with test automation.

CTA-StartTrial-8

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

Related Posts

Introduction to Behavior Driven Development

In a traditional software development process, developers write programs and build features, and testers then test the written pieces of software. However, businesses are now operating at a faster pace and, therefore, software development needs to keep up with business demands.

A Short Introduction to Data-Driven Testing

There are several methodologies available for implementation in software testing. However, not all require the same effort to create and maintain these tests. If you need to run the same tests, but with different parameter values, then you can easily do this through Data-driven testing (DDT).

How to Automate Regression Testing

Software is continuously evolving through changes, updates, and bug fixes. However, even the smallest of the changes can have a domino effect in an application’s source code.