Right Click Disabled

Thursday, February 23, 2012

Dictionary Object

Dictionary is used to store pairs of data and every pair first value is called as Key and second value is called as Item. To access this dictionary pairs we can use an object called as dictionary object.

The corresponding dictionary object can create an interface between QTP tool and a dictionary in memory (RAM). To create dictionary object and access dictionary content using that object, we can use below code in VBScript in QTP tool:

Option explicit
Dim dico
Set dico=CreateObject("Scripting.Dictionary")

In the above code createobject() function is used to create an object for specified data structure. Here “dico” is an object for a dictionary.

To store data into dictionary as pairs, dictionary object is providing a function or method like shown below:

Option explicit
Dim dico
Set dico=CreateObject("Scripting.Dictionary")
dico.Add "English", 78
dico.Add "Hindi", 65
dico.Add "Maths", 98
dico.Add "Computers", 90
dico.Add "Physics", 80

While adding pairs of data to dictionary using dictionary object, corresponding test automater can maintain unique values for Keys.

No comments:

Post a Comment

Twitter Bird Gadget