Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Control values do not refresh synchronously when executing scripts in TestComplete

Shulou Source: shulou.com Published: 2022-06-03 07:24:14 09月17日 Update

Today, I wrote an automatic script for program installation. When debugging, I found that the values of some controls were not automatically refreshed. In view of this problem, after careful analysis and consultation, we found that TestComplete will not automatically refresh the changed values in the control, which requires us to control the refresh ourselves.

1. Define a delay function (parameter: number of seconds delay, condition of execution delay)

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 control that displays the progress (the value:0%-100% of the control):

Set InstallProgress = Aliases.SQLNav.frmSQLNavWizard.panelMain.panelFrameHolder.SelectProduct.pnlNewProducts.pnlRightInstallProgress.labelInstallProgress

3. Call the function in the script:

Call TimeDelay (2) InstallProgress.Caption "100%")

Discovery will be delayed until the specified interval Time Out is exceeded. As analyzed above, the value of the control InstallProgress.Caption is not dynamically refreshed, and the value at the time of the call is obtained, which has not been changed since then.

4. Modify the script:

For controls with dynamic values, it is obviously not appropriate to use the above delay function. For delay processing under controls with dynamic values, you can write a separate script to deal with it, and use the method RefreshMappingInfo () that comes with TestComplete to refresh the control only:

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 add sys.refresh () to the function to refresh the entire program, but this is not recommended, the whole refresh is very performance-consuming.

Tags: Controls delays scripts functions dynamics programs analysis processing problems appropriateness causes parameters that is suggestions performance methods time conditions schedule Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Xiaomi OPPO Reno Huawei Redmi