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 res
Solution 1:
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;
publicclassQ_44643596_measurement_application_load {
publicstaticvoidmain(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:\\Utility\\BrowserDrivers\\chromedriver.exe");
WebDriverdriver=newChromeDriver();
WebDriverWaitwait=newWebDriverWait(driver, 30);
longstart= System.currentTimeMillis();
driver.get("https://stackoverflow.com/");
booleanpageLoaded= wait.until(ExpectedConditions.jsReturnsValue("return document.readyState")).equals("complete");
longfinish= System.currentTimeMillis();
System.out.println("Page has loaded? " + pageLoaded);
longtotalTime= finish - start;
System.out.println("Total Time (in Milli Seconds) for page load - "+totalTime);
}
}
Post a Comment for "Measurement Of Ui Application Page Load Time"