Today, I wrote an automated script for program installation. During debugging, I found that some controls were not automatically refreshed after their values were obtained. In view of this problem, after careful analysis and consultation, testcomplete does not automatically refresh the changed values in the control. Therefore, we need to control the refresh.
1. Define a delay function (parameter: delay seconds, execution delay condition)
Function timedelay (delayseconds, condition)
Dim interval, starttime
Starttime = Time
Do While cbool (condition)
Sleep (delayseconds * 1000)
Interval = second (time-starttime)
If interval = 40 then
Log. Error ("time out .")
Exit do
End if
Loop
End Function
2. namemapping a progress display control (value of the control: 0%-100% ):
Set installprogress = aliases. sqlnav. frmsqlnavwizard. panelmain. panelframeholder. selectproduct. pnlnewproducts. pnlrightinstallprogress. labelinstallprogress
3. Call a function in a script:
Call timedelay (2, installprogress. Caption <> "100% ")
The latency is found until the specified time out is exceeded. The reason is that the installprogress control is analyzed at the top. the value of caption is not dynamically refreshed. the value obtained during the call remains unchanged.
4. Modify the script:
For controls with dynamic values, it is obviously not suitable to use the above delay function. For latency processing under controls with dynamic values, you can write a script separately for processing, use the refreshmappinginfo () method that comes with testcomplete to refresh the control:
Dim begintime
Begintime = Time
Do While installprogress. Caption <> "100%"
Sleep (2000)
Installprogress. refreshmappinginfo
If second (time-begintime) = 40 then
Log. Error ("time out .")
Exit do
End if
Loop
Or you can add SYS. Refresh () to the function to refresh the entire program. However, we do not recommend that you use this method. The overall refresh is performance-consuming.
This article is from the "qytag (upspringing)" blog, please be sure to keep this source http://qytag.blog.51cto.com/6125308/1568748
The control part value is not refreshed synchronously when the script is executed in testcomplete.