Measurement of UI application page load time

I have recently started working on UI testing and was wondering if there is any tool to figure out the time it takes to load the UI page to load in browser including the server response time ( i mean total browser time from request send till page load ). I know that firebug/developer tools can be used to find it manually but is there any other way of doing it. Using selenium, i could use firefox driver and find out the time it takes to get the page and report that time, but i am not sure if it is the correct time.

Answers:

Answer

A few words about the solution:

We will take help of Google Chrome browser for our reference. As we know when a page loads completely the browser returns Document.ReadyState as Complete to Selenium. That's when Selenium executes the next line of code. We will start the timer and start loading the webpage. When ever the document.readyState will be set to complete we will stop the timer. Here is the Selenium-Java code block:

package demo;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class Q_44643596_measurement_application_load {

    public static void main(String[] args) {


        System.setProperty("webdriver.chrome.driver", "C:\\Utility\\BrowserDrivers\\chromedriver.exe");
        WebDriver driver =  new ChromeDriver();
        WebDriverWait wait = new WebDriverWait(driver, 30);
        long start = System.currentTimeMillis();
        driver.get("https://stackoverflow.com/");
        boolean pageLoaded = wait.until(ExpectedConditions.jsReturnsValue("return document.readyState")).equals("complete");
        long finish = System.currentTimeMillis();
        System.out.println("Page has loaded? " + pageLoaded);

        long totalTime = finish - start; 
        System.out.println("Total Time (in Milli Seconds) for page load - "+totalTime);

    }

}

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.