Loop Through Array Returned by Script in Keyword Test
I've written a large amount of script which use arrays to reduce the the data reads from the Excel spreadsheat and improve performance. I recently discovered that, unlike keyword tests, script references don't get renamed when objects are renamed and want to move this logic into keyword tests. However, I can't figure out how to interate through the array within the Keyword test. I'm storing the array in the Keyword a variable (AllCribs) and verified the values are correct (second image). However when attempting either a loop or forloop I'm receiving the exception 'The variable specified as the Loop Counter is of an invalid type. Expected types: Integer, Double'. What am I doing doing wrong?
Here's the script:
// // Return list of ALL cribs // function ReadAllCribs() { var AllCribs = []; Project.Variables.Cribs.Reset(); while (!Project.Variables.Cribs.IsEOF()) { AllCribs.push(Project.Variables.Cribs.Value("CribNumber")); Project.Variables.Cribs.Next(); } return AllCribs; }
And here's the Keyword test
djadhav wrote:The first option you can try it is just leave it blank. TestComplete should automatically take care of it.
If that doesn't work, you can read here (https://support.smartbear.com/viewarticle/73935/#Creating) and create a test variable of integer type for this use.
Option two is the answer -- thank you!!!