How to know the exact time to load a page using Selenium WebDriver?

0 votes
We use Thread.sleep, implicitlyWait and WebDriverWait

but How can we find the exact time to load a page using Selenium WebDriver?
Aug 23, 2018 in Selenium by Atul
• 10,240 points
1,257 views

1 answer to this question.

0 votes

Normally WebDriver should return control to your code only after the page has loaded completely.

So the following Selenium Java code might help you to find the time for a page load -

long start = System.currentTimeMillis();

driver.get("Some url");

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

If this does not work then you will have to wait until some element is displayed on the page -

 long start = System.currentTimeMillis();

driver.get("Some url");

WebElement ele = driver.findElement(By.id("ID of some element on the page which will load"));
long finish = System.currentTimeMillis();
long totalTime = finish - start; 
System.out.println("Total Time for page load - "+totalTime); 
answered Aug 23, 2018 by Meci Matt
• 9,420 points

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer

How to scroll the Page up or down in Selenium WebDriver? (using java)

Its pretty simple. Check out the below ...READ MORE

answered Apr 5, 2018 in Selenium by nsv999
• 5,090 points
7,879 views
0 votes
2 answers

How to set Page Load Timeout using C# using Selenium WebDriver

driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(15); READ MORE

answered Apr 16 in Selenium by Tim Muir
1,725 views
0 votes
1 answer

How to set Page Load Timeout using C# and Selenium Webdriver

Check this out C# WebDriver API now contains ...READ MORE

answered Aug 3, 2018 in Selenium by Samarpit
• 5,130 points
1,876 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,090 points
780 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
1,025 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
727 views
0 votes
1 answer

How to take screenshot of a frame using Selenium WebDriver?

you can use the below code: import java.awt.image.BufferedImage; import ...READ MORE

answered Jun 20, 2018 in Selenium by Meci Matt
• 9,420 points
737 views
0 votes
1 answer