How can we get exact time to load a page using Selenium WebDriver?

0
0

How can we get exact time to load a page using Selenium WebDriver?

We use Thread.sleep

We use implicitlyWait

we use WebDriverWait

but How can we get exact time to load a page using Selenium WebDriver?

  • You must to post comments
0
0

If you are trying to find out how much time does it take to load a page completely using Selenium WebDriver (a.k.a Selenium 2).

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 till 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);
  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Website