Timing page load times in Selenium
Your stopwatch function should work. In addition, for Selenium to capture the load time at reasonable precision, reduce the amount of wait time between commands. I, typically, use the following logic -
StopWatch s = new StopWatch();s.start();while (selenium.isElementPresent("element_locator")) { selenium.setSpeed("10"); Thread.sleep(10);}s.stop();System.out.println("elapsed time in milliseconds: " + s.getElapsedTime());
Here is some more information on the StopWatch
class.