Collection

According to MSDN a Collection object is an ordered set of items that can be referred to as a unit. The Collection object provides a convenient way to refer to a related group of items as a single object. The items, or members, in a collection need only be related by the fact that they exist in the collection. Members of a collection don't have to share the same data type.

Once a collection is created, members can be added using the Add method and removed using the Remove method. Specific members can be returned from the collection using the Item method, while the entire collection can be iterated using the For Each...Next statement.

It means that a collection is a COM object that has 3 properties and 2 methods: Add, Remove, Count, Item and _NewEnum, though in technical literature you may find that only Count and _NewEnum are necessary for the object to be called the collection. 

in QTP: 
Collections methods (add, remove) don't work
_NewEnum i have not seen any practicale application yet. but when we do for each it used internally. 
 item: 
Following two statements are equal as item is the default property:

Set desc=Description.Create()
desc("micclass").value="Link"
desc("html tag").value="A"

Set cLiks=Browser("Gmail: Email from Google").Page("Gmail: Email from Google").ChildObjects(desc)

For i=0 to  cLiks.count

print cLiks(i).getroproperty("text")  '- Same as below

print cLiks.item(i).getroproperty("text") '- same as above
Next


 

Comments

Popular posts from this blog

Arrays

What is the difference between eval, execute and executeglobal.

Sample Test Strategy for a MicroService Project with APIs only