0

I am planning to develop code for measure Web page loading time using HtmlUnit

Below is my code

public static void main(String[] args) throws IOException {
    final WebClient webClient = new WebClient(BrowserVersion.CHROME);
    webClient.getOptions().setUseInsecureSSL(true);
    final HtmlPage page = webClient.getPage("http://www.gmail.com/");
    long time = page.getWebResponse().getLoadTime();
    long loadEventEnd = Long.parseLong(page.executeJavaScript("window.performance.timing.loadEventEnd").getJavaScriptResult().toString());
    long navigationStart = Long.parseLong(page.executeJavaScript("window.performance.timing.navigationStart").getJavaScriptResult().toString());
    long timejs = loadEventEnd-navigationStart;        
    System.out.println("Html Unit Time : " + time + " JS Time : "+timejs);
}

when i execute the code each every time i got same result in the "timejs"

(i am comparing both times as a test)

i am stuck in here, please help me

1 Answer 1

1

The timing API is more or less a mock at the moment (version 2.32). Have a look at the code.

As always patches are welcome.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.