What is best way to get response time for each page load?

124 views
Skip to first unread message

neversaydie

unread,
Aug 6, 2009, 8:56:18 AM8/6/09
to webdriver
Hello,

I have few test suites running using testng, one of the requirement
is that system should be able to capture time log for page load time
for each of the test run in a test suite. I am using testng listeners
to log test run time but not the page load time.

Has anybody come across this type of issue? How to do it?

Thank for your help in advance.


James Prickett

unread,
Aug 7, 2009, 10:49:08 AM8/7/09
to webdriver
one suggestion is you could extend, say, HtmlUnitDriver, and overload
the get() method as such:

public void get(String url) {
long start = System.currentTimeMillis();

super.get(url);

long end = System.currentTimeMillis();
long duration = end - start;
LOGGER.INFO("Page took " + duration + " ms to load");
}

hth,
-j

Simon Stewart

unread,
Aug 12, 2009, 6:05:17 AM8/12/09
to webd...@googlegroups.com
Alternatively, consider using the EventFiringWebDriver, which will
alert you as key events happen:

http://webdriver.googlecode.com/svn/javadoc/org/openqa/selenium/support/events/EventFiringWebDriver.html

You'll want to extend the AbstractWebDriverEventListener and override
the {before|after}NavigateTo handlers.

http://webdriver.googlecode.com/svn/javadoc/org/openqa/selenium/support/events/AbstractWebDriverEventListener.html

Regards,

Simon
Reply all
Reply to author
Forward
0 new messages