O'Reilly logo

Selenium Testing Tools Cookbook by Unmesh Gundecha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Measuring the response time using a timer

Measuring page load or response time is one of the basic metrics that we can capture in the Selenium WebDriver tests. We can use timers in the test code to capture the time taken for page load, rendering of the elements, JavaScript code execution, and so on. This approach can be implemented using the Date/Time classes in programming languages.

We can also use the Stopwatch class to measure the time taken for an activity of interest. The only downside of this approach will be testing with a lot of timers added.

In this recipe, we will see how to calculate the timespan between two events in various ways.

Getting ready

We need to identify the areas where we we need to evaluate the response time. We will measure ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required