pramod_tr_rao
12 years agoOccasional Contributor
Test Complete does not wait until the entire Page/Frame is loaded even though we wait for the ready state to be complete
Hi,
We have an issue where Test Complete performs operation on an object even before the entire Page/Frame is loaded. We have put in a function that checks and waits until the readystate of the page/frame is complete. After this step we click on the object, but most of the times testcomplete does not end up clicking on the item as the page/frame is not completely loaded.
Due to this all our scripts are failing due to Sync issues. We do not want to add in a Hard Coded Wait, so please let me know if you have any suggestions on how we can implement a solution to this issue.We also have a while loop that waits for the object until it exists or a max delay timeout is reached. so we are waiting for the object to be VisibleOnScreen as well,but still we are facing this sync issue. PLEASE HELP..KINDA URGENT...
Thanks,
Pramod
Please find the code for the WaitTimeOut function below.
Function bWaitTimeOut()
On Error Resume Next
Dim intStopTime
Dim arrFrames,objFrame
Dim intCounter, bWaitStatus
bWaitTimeOut = True
bWaitStatus = False
intStopTime = GetTickCount() + gdblMaxDelayTime
Do While GetTickCount() < intStopTime
arrFrames = uobjPage.FindAllChildren("ObjectType", "Frame", 5, True)
If UBound(arrFrames) >= 0 Then
bWaitStatus = False
For intCounter = 0 To UBound(arrFrames)
Set objFrame = arrFrames(intCounter)
If objFrame.Exists And objFrame.contentDocument.readyState <> "complete" Then
bWaitStatus = True
Exit For
End If
Next
aqUtils.Delay(100)
Else
bWaitStatus = False
If uobjPage.Exists And uobjPage.readyState <> "complete" Then
'If Sys.Process(gstrBrowserType).readyState <> "complete" Then
bWaitStatus = True
End If
aqUtils.Delay(100)
End If
If Not bWaitStatus Then
Exit Do
End If
Loop
'Wait for the page to be completely loaded
uobjPage.Wait
If Err.Number <> 0 Then bWaitTimeOut = False
End Function
We have an issue where Test Complete performs operation on an object even before the entire Page/Frame is loaded. We have put in a function that checks and waits until the readystate of the page/frame is complete. After this step we click on the object, but most of the times testcomplete does not end up clicking on the item as the page/frame is not completely loaded.
Due to this all our scripts are failing due to Sync issues. We do not want to add in a Hard Coded Wait, so please let me know if you have any suggestions on how we can implement a solution to this issue.We also have a while loop that waits for the object until it exists or a max delay timeout is reached. so we are waiting for the object to be VisibleOnScreen as well,but still we are facing this sync issue. PLEASE HELP..KINDA URGENT...
Thanks,
Pramod
Please find the code for the WaitTimeOut function below.
Function bWaitTimeOut()
On Error Resume Next
Dim intStopTime
Dim arrFrames,objFrame
Dim intCounter, bWaitStatus
bWaitTimeOut = True
bWaitStatus = False
intStopTime = GetTickCount() + gdblMaxDelayTime
Do While GetTickCount() < intStopTime
arrFrames = uobjPage.FindAllChildren("ObjectType", "Frame", 5, True)
If UBound(arrFrames) >= 0 Then
bWaitStatus = False
For intCounter = 0 To UBound(arrFrames)
Set objFrame = arrFrames(intCounter)
If objFrame.Exists And objFrame.contentDocument.readyState <> "complete" Then
bWaitStatus = True
Exit For
End If
Next
aqUtils.Delay(100)
Else
bWaitStatus = False
If uobjPage.Exists And uobjPage.readyState <> "complete" Then
'If Sys.Process(gstrBrowserType).readyState <> "complete" Then
bWaitStatus = True
End If
aqUtils.Delay(100)
End If
If Not bWaitStatus Then
Exit Do
End If
Loop
'Wait for the page to be completely loaded
uobjPage.Wait
If Err.Number <> 0 Then bWaitTimeOut = False
End Function
- Hi Pramod,
Does your tested web page contain script(s) code that modify the content of the page?
The case is that browsers set the page ready flag (that TestComplete looks for) when the page is obtained from the server. Then, the browser executes scripts on the page. But this happens with the ready flag already set. Depending on the scripts, browser and local system load, scripts execution can take significant time.
According to my experience, the best way is to wait until the page is loaded (page.Wait). Then, it is really good if you can find some object that, if found on the page, indicates that the browser completed scripts processing and the page is ready to interact with the end-user. Wait for this object to exists.
Then you may proceed with the test using your current approach: not to try to perform some action against some object on the page, but first check if this object exists and wait (using timeout) until the object appears if it was not found. And only after the object was found, proceed with the actions against it.
The described approach works pretty well for me for several highly scripted web applications.
Hope this will help.