I'm using selenium to log some performance tests on my site. for example login times, query times, etc. I have a sample script recorded on Selenium IDE. I now have it running one Selenium RC (java).
public void testNew() throws Exception {
selenium.open("/jira/secure/Dashboard.jspa");
selenium.selectFrame("gadget-10371");
selenium.type("login-form-username", "username");
selenium.type("login-form-password", "pw");
selenium.click("login");
selenium.waitForPageToLoad("30000");
selenium.selectWindow("null");
selenium.click("find_link");
selenium.waitForPageToLoad("30000");
selenium.removeSelection("searcher-pid", "label=All projects");
}
How would I log how long the from clicking the login button to fulling loading the "logged in" screen?
Heres what I came up with, would this be an accurate timing? :
long starttime = System.currentTimeMillis();
selenium.waitForPageToLoad("30000");
long stoptime = System.currentTimeMillis();
long logintime = stoptime - starttime;
System.out.println(logintime+" ms" );
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With