Forum Discussion

rjqajob's avatar
rjqajob
Occasional Contributor
15 years ago

Page response time

Hi,



I want to measure the page response time i.e when I clicked on a button a new page opens.I want to know how much time it took to open the page.Please let me know the code for this.



Thanks,

Dhanu

6 Replies

  • Hello Dhanu,




    To measure the page loading time, you can measure the time taken by the Page.Wait function to work.


    Here is a sample script demonstrating how to do this:







    function Test()


    {


      var  iexplore, page, startTime, loadTime;


      


      iexplore = Sys.Process("IEXPLORE");


      page = iexplore.Page("*");


      page.ToUrl("http://www.automatedqa.com/");


      page.Form("aspnetForm").Panel(1).Panel(0).Panel(1).Panel(0).Link(6).Click();




      startTime = GetTickCount();


      page.Wait();


      loadTime = GetTickCount() - startTime;


      Log.Message("Page load time: " + loadTime + " ms");


    }


  • U can use HISUtils.StopWatch before and after the pageload to capture the time in milliseconds.
  • rjqajob's avatar
    rjqajob
    Occasional Contributor
    Hi Alex,



    Thank you. Can you send me VB script code.
  • Hi,



    Here is the VBScript version:





    Sub Test

     
    Dim iexplore, page, startTime, loadTime



      Set iexplore = Sys.Process("IEXPLORE")

      Set page = iexplore.Page("*")

     
    page.ToUrl("http://www.automatedqa.com/"

     
    page.Form("aspnetForm").Panel(1).Panel(0).Panel(1).Panel(0).Link(6).Click



     
    startTime = GetTickCount

     
    page.Wait

     
    loadTime = GetTickCount - startTime

      Log.Message("Page load time: " & loadTime & " ms")

    End Sub

  • HI,



    What if i want to caculate the Loading Time of main page. E.g. i am opening www.smarbear.com and want to know how much time it took to display. ToURL and NavigateTo method are not working because Wait method is included in these method by default.
  • Hi,



    Call the Win32API.GetTickCount function before Wait and then call it after Wait. The difference between its results before and after Wait will give you the number of milliseconds it took your page to load.