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
myxl.ActiveWorkbook.Save
myxl.ActiveWorkbook.Close
myxl.Application.Quit
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 ("----------------------------------------------------------------------------------------")
objWTS.WriteBlankLines(1)
objWTS.Close
Set fso = nothing
Set objWTS = nothing
End Function
'MAIN CODE
available = true
startTime = timer
Do
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"
ExitTest
Else
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.
Check
andCheckpoint
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 thewrite_log
is only to report what checkpoint is passed, but the problem is that the checkpoint pass, but thewrite_log
and theExist Do
is not executed.Check
andCheckPoint
are executed but do not pass. If they passed then I would expect thewrite_log path, "chk_point_1_v... passed"
to write something and that is why I asked for the output of thewrite_log
lines.Checkpoint
to theCheck
. Also, from their example it looks likeCheck
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/…= true
inside theif
, only put a parentheses between theCheckpoint
. Now it's working. Thanks for the help guys, the thread can be closed.