Measure response time when a part of the page is refreshed

Scripts for common tasks

Measure response time when a part of the page is refreshed

Postby Mike on Wed Dec 16, 2009 10:44 am

With a UsePage, the script waits until the specified page is there, even if the page title did not change after the previous click. So UsePage makes an automatic synchronization.
On pages where only a part of the page is refreshed, the UsePage is not enough to measure how long it takes for the part of the page to load.
The function below can be used for this specific case.
Code: Select all
Function wait_html_element_exist(html_element$, timeout)
' The function waits for a maximum of timeout secs that the element
' specified by its HTML descriptor, html_element$ is there.
local elapsedTime
local elementthere
local ret

elapsedTime = 0
elementthere = 0
   ret = ExistHTMLElement(html_element$)
   If (ret = 1) Then
      ' Element is there
      elementthere = 1
      elapsedTime = elapsedTime + 1
      ' A small Pause to allow the system to do something else.
      Pause 10 Ticks
Until (elementthere = 1) Or (elapsedTime > timeout)

' Set function return value based on whether element exists or not.
wait_html_element_exist = elementthere

'Call example
StartBrowser("IE", "")

UsePage("WinTask - Automation software and Task Scheduler. Macro software with Macro Recorder")
   ClickHTMLElement("A[INNERTEXT= 'How It Works']")

ret=wait_html_element_exist("P[CONTENT='WinTask is']", 10)
'The function returns 1 if the element is there within 10 secs, 0 if not
Posts: 5
Joined: Fri Dec 04, 2009 3:24 pm

Return to Sample Scripts and Tips

Who is online

Users browsing this forum: No registered users and 1 guest