Let me share with you an approach that I implemented in Java, but perhaps you can adapt it to VB.NET.
public class CodeTimingMeasurement extends BaseSeleniumTest {
@Test
public void measurePageLoadTime() throws IOException, InterruptedException {
performLogout();
locateElement("login.logininput", "login.admin.login");
locateElement("login.passinput", "login.admin.pass");
long startTime = System.currentTimeMillis();
locateElement("login.loginbutton");
waitForLoaderToDisappear("rms.loadingwindow");
waitUntilVisible(By.cssSelector(getProperty("rms.home.timeoffs.gearicon")));
waitUntilVisible(By.cssSelector(getProperty("rms.home.logout")));
waitUntilVisible(By.cssSelector(getProperty("home.timeoffs.own")));
long endTime = System.currentTimeMillis();
long totalTime = endTime - startTime;
System.out.println("Total time taken: " + totalTime + " milliseconds");
}
}
The concept is simple:
Click on a button or element triggering the page load. Start a timer. Identify and wait for a set of elements expected to be displayed on the page using fluentWait mechanism. Stop the timer once all elements are visible.
More information on fluent wait here.
Code for fluent wait method:
public WebElement waitForElement(final By locator){
Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)
.withTimeout(30, TimeUnit.SECONDS)
// .pollingEvery(5, TimeUnit.SECONDS)
.pollingEvery(1, TimeUnit.SECONDS)
.ignoring(NoSuchElementException.class);
WebElement element = wait.until(
new Function<WebDriver, WebElement>() {
public WebElement apply(WebDriver driver) {
return driver.findElement(locator);
}
}
);
return element;
};
I hope this explanation clarifies things for you)