Dictonary Object
Dictionary Object
Dictionary Object stores data key, item pairs. A Dictionary object stores the items in the array. Each item is associated with a unique key. The key is used to retrieve an individual item and is usually an integer or a string, but can be anything except an array.
Adavntages of using it in QTP:
1. can be used as Global variable declaration. so that any test can access the values from it in the run time.
2. You can store and retrive any number of run time values in to dictonary.
3. It is one of the Parameterization techique we can use in QTP
Disadvantages:
we can not specify the values in the desingn time like Datatable , Action parameters, environment variable.
So it is useful only in Run time , not design time
Methods:
Add Method
Adds a key and item pair to a Dictionary
object. object.Add (key, item)
Arguments
object Required. Always the name of a Dictionary object.
key Required. The key associated with the item being added.item Required.
The item associated with the key being added.
Remarks
An error occurs if the key already exists.
The following example illustrates the use of the Add method.
Dim d ‘ Create a variable.
Set d = CreateObject(“Scripting.Dictionary”)
d.Add “a”, “Athens” ‘ Add some keys and items.
d.Add “b”, “Belgrade”
Items Method
Returns an array containing all the items in a Dictionary object.
Remarks The object is always the name of a Dictionary object.The following code illustrates use of the Items method:
Exists Method
Returns true if a specified key exists in the Dictionary object, false if it does not.
object.Exists(key)
Arguments
object Required. Always the name of a Dictionary object.
key Required. Key value being searched for in the Dictionary object.
Remarks
The following example illustrates the use of the Exists method.
Keys Method
Returns an array containing all existing keys in a Dictionary object.
object.Keys( )
Remarks
The object is always the name of a Dictionary object.
The following code illustrates use of the Keys method:
Remove Method
Removes a key, item pair from a Dictionary object.
object.Remove(key)
Arguments
object Required. Always the name of a Dictionary object.
key Required. Key associated with the key, item pair you want to remove from the Dictionary object.
Remarks
An error occurs if the specified key, item pair does not exist.
The following code illustrates use of the Remove method:
RemoveAll Method
The RemoveAll method removes all key, item pairs from a Dictionary object.
object.RemoveAll( )
Author: Mohan Kakarla
Reference:MSDN
-
Archives
- July 2011 (1)
- March 2011 (1)
- November 2010 (1)
- November 2008 (4)
- October 2008 (2)
- September 2008 (2)
- June 2008 (1)
- March 2008 (4)
- February 2008 (44)
-
Categories
- Automated Test Script Creation Process
- Automating MS Word
- Automating QC
- Automation Object Model For QTP
- Backward compatability in QTP
- Browser Scripts
- COM and QTP
- compare 2 text files
- Descriptive programming
- Descriptive Programming and Child Objetcs
- Dictonary Object
- DotNetFactory
- Excel Automation
- Extra Topics
- Files and Folders
- General Standards to be followed in Test scripts
- New Features In QTP9.5
- QC-OTA
- QTP Additional Faqs
- QTP Faqs
- QTP Naming Convention
- QTP Tips and Faqs
- Running stored procedures from QTP
- Send keyboard keys
- Uncategorized
- Uninstall a software using QTP
- Uninstall a software using vbscript
- Update data in a database
- VBScript and IE Automation
- VBScript Faqs and Useful resources
- What’s New in Quick Test Pro 9.0
- Whats New in QTP 9.5
- XML Scripting
-
RSS
Entries RSS
Comments RSS