Forum Discussion

sekhan's avatar
sekhan
Occasional Contributor
13 years ago

array in testcomplete 7

Hi all,



I want to get all of web browsers from my computer, I use array to contain the web browsers:



var listofbrowsers;

listofbrowsers = new Array();

//code to get web browsers from computer

...

//add web browser into array

listofbrowsers.AddItem("Firefox " + ffVerName);



When run my test, I get error message: "Object doesn't support this property or method".

Is AddItem method not supported for array object?



Thanks

3 Replies

  • Hi Vu,



    You are right, the Array object does not have the AddItem method. To add elements to a JScript array, just use the assignment:

    var listofbrowsers;
     

    listofbrowsers = new Array();


    ...


    listofbrowsers[0] = "Firefox " + ffVerName;


    listofbrowsers[1] = ...;


  • sekhan's avatar
    sekhan
    Occasional Contributor
    oh. I found the AddItem method from TC7 help file: ArrayObject_Obj.AddItem(Value)

    I don't understand its usage clearly. Can you explain me again?



    Thanks

  • Hi Vu,



    ArrayObject is used for ODT objects, not to create variant arrays. According to your task, you need to create an array of strings. For this purpose, JScript arrays are used. Follow the link from my previous post to find a description of these arrays.



    BTW, the latest version of TestComplete is 8.60.