I need to measure response time for a website.
Response time to open a page of a web site: I mean the loading time, some way to see the difference in time before and after open a website page.
But this way, measuring the client loading time, will depend on the client used client. What is the best way to measure that?
long startTime = System.currentTimeMillis(); driver.get("http://zyxware.com"); new WebDriverWait(driver, 10).until(ExpectedConditions.presenceOfElementLocated(By.id("Calculate"))); long endTime = System.currentTimeMillis(); long totalTime = endTime - startTime; System.out.println("Total Page Load Time: " + totalTime + "milliseconds");
or this?
driver.get("url");
WebElement ele = $(By.tagName("body"));
// get the page load time
Long loadtime = (Long)((JavascriptExecutor)driver).executeScript(
"return performance.timing.loadEventEnd - performance.timing.navigationStart;");
System.out.println(loadtime);
and last way the following:
StopWatch pageLoad = new StopWatch();
pageLoad.start();
//Open your web app (In my case, I opened facebook)
driver.get("url");
// Wait for the required any element (I am waiting for Login button in fb)
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.presenceOfElementLocated(By.tagName("body")));
pageLoad.stop();
//Get the time
long pageLoadTime_ms = pageLoad.getTime();
long pageLoadTime_Seconds = pageLoadTime_ms / 1000;
System.out.println("Total Page Load Time: " + pageLoadTime_ms + " milliseconds");
- if I have a search button for the same website, if I need to measure the search time, how to do it? is it as same as the above way?
search time
? Does that include the time to render the search results page?