How to get exact page load time for all web pages using Selenium WebDriver with Java?

Hmm, it sounds tricky, finding how much time does it take for a page to load that we navigate to from our automation script. But, its possible using Selenium WebDriver with Java.

Following code snippet may help us getting the page load time.

Step 1 : Create file, which extends AbstractWebDriverEventListener class, overrides two event methods as shown in code snippet.

public class WebDriverEventListenerClass extends AbstractWebDriverEventListener {

             long startTime, endTime;

             public void beforeNavigateTo(String arg0, WebDriver arg1) {
                          startTime = System.currentTimeMillis();

             public void afterNavigateTo(String arg0, WebDriver arg1) {

                         endTime = System.currentTimeMillis();
                        System.out.println(“Page load time for ” + arg0 + ” is (in milliseconds) : ” + (endTime – startTime));



To know more about Listener events visit What is Listeners in Selenium WebDriver?

Step 2 : Create file, contains a simple automation script which opens a

public class GetPageLoadTime {

             public static void main(String[] args) {

                          WebDriver ffDriver = new FirefoxDriver();

                          EventFiringWebDriver driver = new EventFiringWebDriver(ffDriver);
                          WebDriverEventListenerClass eventListener = new WebDriverEventListenerClass();



Output : On console, the page load time for will be displayed in milliseconds.

Visit What is Listeners in Selenium WebDriver? for more information about Event listeners in Selenium WebDriver.

Hope you liked it!

Cheers 🙂


#abstractwebdrivereventlistener, #get-page-load-time-in-selenium-webdriver, #listeners-in-webdriver, #webdriver