API test that calls GUI test hangs iterations

Question ID: 108968

My API test calls a GUI test. After running the GUI test, it won’t continue running iterations. The first iteration runs without a problem, but subsequent iterations hang and never complete. It happens only with one specific GUI script (See code below).

CustomerNumber = 649877
FilePath = "C:\\TestFiles\\CustomerList.txt"
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.OpenTextFile(FilePath,1, True)
MyText = Split(MyFile.ReadAll,";") ‘Splits file into arrays

UpperBound = ubound(MyText)
For CustNo = 0 to UpperBound
If InStr(MyText(CustNo), CustomerNumber) > 0 Then
CustomerNumberFound = True
End If

Marked as spam
Posted by (Questions: 344, Answers: 24)
Asked on April 26, 2019 4:27 pm
Answers (1)
Private answer

Any time you access the file system, you should close the connections, otherwise it could cause problems with UFT releasing the file. Add this code ad the end of your script and see if it works:

Set MyFile = Nothing
Set fso = Nothing

Marked as spam
Posted by (Questions: 16, Answers: 754)
Answered on April 26, 2019 4:27 pm
That worked for us. Thanks for the tip!
( at April 26, 2019 4:28 pm)