Overview
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.
Advantages of using it in UFT/QTP:Can be used as Global variable declaration. so that any test can access the values from it in the run time.
You can store and retrieve any number of run time values in to dictionary.
It is one of the Parameterization technique we can use in QTP
Disadvantages:we can not specify the values in the design time like Datatable , Action parameters, environment variable. So it is useful only in Run time , not design time
Code
'Sample code to retrieve all Keys of dictionary. replace the keyword Keys with Items to get all the list of items in dictionary
Set o1 = createobject("Scripting.dictionary")
o1.Add "QTP","Fucntional Testing Tool"
o1.Add "Load Runner","Performance Testing tool"
o1.Add "Service Test","Speciality in WebSerices"
o1.Add "Sprinter","ALM Connection needed"
arrDict = o1.Keys
For i = 0 To Ubound(arrDict)
msgbox arrDict(i)
Next
'Some time you may require to get the Key and Item pair
Set o1 = createobject("Scripting.dictionary")
o1.Add "QTP","Fucntional Testing Tool"
o1.Add "Load Runner","Performance Testing tool"
o1.Add "Service Test","Speciality in WebSerices"
o1.Add "Sprinter","ALM Connection needed"
arrDict = o1.Keys
For i = 0 To Ubound(arrDict)
msgbox "Key - '" & arrDict(i) & "' Item - '" & o1.Item(arrDict(i)) & "'"
Next
Overview of method and properties that can be handy
'To Create a dictionary - Scripting.Dictionary object should be created
'Set objDictionaryName = Createobject("Scripting.Dictionary")
' Syntax to add a dictionary item
'objDictionaryName.Add(Key,Item)
' To Retrieve an Item
'objDictionaryName.Item(key)
' To retrieve the count of items in dictionary
'objDictionaryName.count
' To Check if a Key exists in a Dictionary
'objDictionaryName.count
' The below code removes the key and its items from the dictionary
'objDictionaryName.Remove(key)
' The below code removes all the keys and Items available in dictionary
'objDictionaryName.RemoveAll
' The below code returns you the array collection of Keys available in Dictionary
'objDictionaryName.Keys
' The below code performs the type of comparison needed on the key
' They are two types of comparison modes - 1) vbTextCompare - in this mode text case sensitivity is ignored
' vbBinaryCompare - in this mode text case sensitivity will be taken into consideration
'objDictionaryName.CompareMode = vbTextCompare
' here are some examples
strKey = "R2014010175489"
strItemVal = "Mike Tuffer"
Set objDict = Createobject("Scripting.Dictionary")
objDict.Add strKey,strItemVal
'result - outputItemVal contain the "Mike Tuffer"
outputItemVal = objDict.Item(strKey)
print outputItemVal
'Result - intDictItemsCount contains the number of items already available in Dictionary in the current case it is "1"
intDictItemsCount = objDict.Count
' Below code checks if key is available in the dictionary
If objDict.Exists(strKey) then
reporter.ReportEvent micPass,"Check Dictionaryfor key " & strKey,"Dictionary contains the key " & strKey
else
reporter.ReportEvent micFail,"Check Dictionaryfor key " & strKey,"Dictionary does not contains the key " & strKey
End if
' The below code returns you the array collection of Keys available in Dictionary
objDict.Keys
' The below code removes the "R2014010175489" and its item "Mike Tuffer" from the dictionary
objDict.Remove(strKey)
' The below code removes all the keys and Items available in dictionary. This is used in Clearing the dictionary items if it has multiple Key, Items pairs
objDict.RemoveAll
' The below code will perform vbtextcomparasion on the Key
objDict.CompareMode = vbTextCompare
Manual Testing Training in Chennai
ReplyDeleteQTP Training in Chennai
Selenium Training in Chennai
SoapUI Training in Chennai
Software Testing Training in Chennai
Diyarbakır
ReplyDeleteSamsun
Antep
Kırşehir
Konya
BVBJWY
A8DC7
ReplyDeleteKarabük Lojistik
Şırnak Parça Eşya Taşıma
Çerkezköy Cam Balkon
Erzurum Evden Eve Nakliyat
Çorlu Lojistik
Isparta Şehir İçi Nakliyat
Malatya Şehir İçi Nakliyat
Bingöl Evden Eve Nakliyat
Tokat Evden Eve Nakliyat
F28B0
ReplyDeleteBingöl Parça Eşya Taşıma
Bolu Parça Eşya Taşıma
Urfa Şehir İçi Nakliyat
Batman Parça Eşya Taşıma
Sui Coin Hangi Borsada
Gümüşhane Lojistik
Pitbull Coin Hangi Borsada
Çorum Şehirler Arası Nakliyat
İzmir Şehir İçi Nakliyat
612F0
ReplyDeleteAnkara Sohbet Siteleri
bilecik rastgele canlı sohbet
uşak canli sohbet chat
istanbul rastgele sohbet siteleri
bayburt mobil sohbet odaları
kayseri kadınlarla ücretsiz sohbet
Antep Canli Goruntulu Sohbet Siteleri
mobil sohbet
en iyi sesli sohbet uygulamaları
9F5F1
ReplyDeletetekirdağ canli sohbet
van görüntülü sohbet siteleri ücretsiz
ankara canlı görüntülü sohbet siteleri
rize bedava sohbet uygulamaları
aydın görüntülü sohbet siteleri
rize yabancı görüntülü sohbet uygulamaları
Erzincan Mobil Sohbet
yabancı sohbet
canli goruntulu sohbet siteleri
762A9
ReplyDeletesakarya rastgele sohbet
Antep Bedava Sohbet Uygulamaları
afyon bedava sohbet chat odaları
Afyon Rastgele Görüntülü Sohbet Uygulamaları
ucretsiz sohbet
Batman Canli Sohbet Chat
sakarya random görüntülü sohbet
chat sohbet
bitlis ücretsiz sohbet sitesi
3D729
ReplyDeletebedava sohbet chat odaları
trabzon telefonda rastgele sohbet
tokat rastgele sohbet uygulaması
balıkesir kadınlarla ücretsiz sohbet
ardahan sohbet muhabbet
Elazığ En İyi Rastgele Görüntülü Sohbet
ısparta Ücretsiz Görüntülü Sohbet
telefonda kızlarla sohbet
yalova canlı sohbet odası
1BA07
ReplyDeleteAybastı
Şirvan
Hocalar
Saraydüzü
Bolvadin
Dazkırı
Toroslar
Şehitkamil
Ferizli