Page load time in Selenium

I use selenium to register some performance tests on my site. e.g. login time, request time, etc. I have a sample script written in the Selenium IDE. Now I run 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 do I log in, how long do you press the login button to fill the loaded screen?

That's what I came up with, will it be the exact time?

  long starttime = System.currentTimeMillis(); selenium.waitForPageToLoad("30000"); long stoptime = System.currentTimeMillis(); long logintime = stoptime - starttime; System.out.println(logintime+" ms" ); 
+6
java performance logging selenium
source share
1 answer

The stopwatch function should work. In addition, for Selenium, to capture boot times with reasonable accuracy, reduce the amount of wait time between commands. I usually 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()); 

There is additional information about the StopWatch class.

+2
source share

All Articles