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.

Read the LEAPWORK Guide to intelligent test automation

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

Related Posts

Comparison: Selenium IDE vs. LEAPWORK

Selenium IDE is a great open source tool for HTML-savvy users who want record and playback automation of simple web applications, but isn’t suitable for enterprises and has very limited functionality. This post compares Selenium IDE with LEAPWORK enterprise web automation.

Comparison: LEAPWORK vs. Selenium Web Automation

Selenium is a great tool for professional programmers who want to automate web applications, but for users who don’t (want to) write code, there are better options. This post compares code-based Selenium with LEAPWORK web automation. Side-by-side video comparison included.

Test Automation Frameworks: Why They Fail

Test automation frameworks are basically recipes for how to build automated test cases. They include guidelines for testers on how they should do their job. The problem is, these frameworks don’t always work, as they tend to complicate test automation more than necessary.