I'm facing a problem with my GUI test. I want to check if a certain screen of an application is loaded or not; for this I'm using a bitmap checkpoint and a test area checkpoint. I'm using both because sometimes the bitmap checkpoint is so sensitive and fails for a little change in the image, so to I decided to use a test area for this.

My problem is that I'm using a infinite loop with a counter timer. If the time becomes greater than X seconds, exit the loop and report. If not, check the checkpoints: if one passes, exit the loop and report. When I run this script, the code does not exit the infinite loop, even though the Results View indicates that the second checkpoint passed! Why didn't it exit the loop?

Also, I used the same code in another action and it works! The only difference is that the other action I'm using has more checkpoints. So I am really not understanding what is happening.

The functions write_log and Report_results are just a way to keep the results. I don't think they are the problem because I checked them individually and they seemed to work fine.

Function Report_results(x1,y1,Value,x2,y2,sheet)

    Set myxl = createobject("excel.application")
    myxl.Workbooks.Open "R:\data\hpc_uat\CAEDev\nbak\czp2hk\bench_log_results_v3.xlsx"
    myxl.Application.Visible = false
    Set mysheet_logs = myxl.ActiveWorkbook.Worksheets(sheet)
    mysheet_logs.cells(x1,y1).value = Value
    mysheet_logs.cells(x2,y2).value = Now 

    Set mysheet_logs = nothing
    Set myxl = nothing

End Function

Function write_log(path, value)

    Set fso = createobject("Scripting.FileSystemObject")

    Set logFile = fso.GetFile(path)

    Set objWTS = logFile.OpenAsTextStream(8,0)

    objWTS.WriteLine (value)
    objWTS.WriteLine ("----------------------------------------------------------------------------------------")

    Set fso = nothing
    Set objWTS = nothing

End Function


available = true

startTime = timer

    If startTime>400000 Then
        Report_results aux, 3, (startTime)/100000, aux, 12, "bench_logs"        
        write_log path, "chk_point_1 not passed, time exceed 40s"
        If (Window("Gompute Desktop:.*").WinObject("gomputeWindow").Check (CheckPoint("chk_point_1_primer_GMB_v1")) = true) Then    
            write_log path, "chk_point_1_v1 passed"
            Exit Do
            End If
        If (Window("Gompute Desktop:.*").WinObject("gomputeWindow").Check (CheckPoint("chk_point_1_primer_GMB_v2")) = true) Then    
            write_log path, "chk_point_1_v2 passed"
            Exit Do
        End If
    End If
Loop While available = true

stopTime = timer

totalTime = stopTime-startTime

write_log path, "chk_point_1 passed"
Report_results aux, 2, totalTime, aux, 12, "bench_logs"

Here is just a sample of the Results Viewer that shows a checkpoint passed, but the code keeps checking the checkpoints, indicating that the code didn't break out of the infinite loop.

enter image description here

  • So, the Checkand Checkpoint is a method of UFT, I only capture the image what I want to check, and UFT make the comparison for me. I can set some tolerances to make sure that it will not fail for a small difference between the images. And the write_log is only to report what checkpoint is passed, but the problem is that the checkpoint pass, but the write_logand the Exist Do is not executed. – Natalia Ribeiro Jun 5 '17 at 14:30
  • I think you mean that the Check and CheckPoint are executed but do not pass. If they passed then I would expect the write_log path, "chk_point_1_v... passed" to write something and that is why I asked for the output of the write_log lines. – AdrianHHH Jun 5 '17 at 14:41
  • Yes, exactly, I expected this too, but for some reason the code not stop to check the checkpoints, even they exceed the timer. – Natalia Ribeiro Jun 5 '17 at 14:50
  • A couple stabs in the dark from looking at uft-help.saas.hpe.com/en/14.00/UFT_Help/Content/User_Guide/… -- they seem to hide a lot of their documentation and I don't use uft, but: 1) is it correct to be comparing a checkpoint to a boolean? their example shows just passing a Checkpoint to the Check. Also, from their example it looks like Check is a procedure, not a function, so try removing the parentheses around the Checkpoint and boolean comparison. See blogs.msdn.microsoft.com/ericlippert/2003/09/15/… – c32hedge Jun 6 '17 at 14:37
  • 1
    Oh you're right! Don't need to put = true inside the if, only put a parentheses between the Checkpoint. Now it's working. Thanks for the help guys, the thread can be closed. – Natalia Ribeiro Jun 7 '17 at 12:31

I don't use uft and they seem to hide a lot of their documentation, but per http://uft-help.saas.hpe.com/en/14.00/UFT_Help/Content/User_Guide/Und_Chkpt_Statements.htm it looks like you should just pass a Checkpoint to the Check without the = true. Otherwise you're actually passing a boolean comparison to Check rather than the actual result of a Checkpoint call (whatever it returns).

I believe the Results Viewer is showing the results of the Checkpoint calls themselves, not the actual result of the Check function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.