SlideShare ist ein Scribd-Unternehmen logo
1 von 3
Dictionary Object In QTP :
The Dictionary object is used to hold a set of data values in the form of (key, item) pairs.
It is also known as 'Associative Array' because it associates a key with an item.
If you compare it with an Array, Keys are similar to the indices in an array. But here Keys are not
numetic Indices like we have in array ranther than these are
arbitrary strings normally. Each key in a single Dictionary object must be unique.
Dictionary Object is a part of VB Script and so it can be used with the tools supporting VBS.
(Here we will talk how it used in QTP).
Dictionary object is COM object(Component Object Model) and “Scripting.Dictionary” is the ProdID
for Disctionary object.
It can be instantiated as following:
Dim oDict
Set oDict = CreateObject("Scripting.Dictionary")
Using Add method we can add fdifferent keya and pair values to the structure.
Set oDict = CreateObject("Scripting.Dictionary")
oDict.Add "Tool1", "Selenium"
oDict.Add "Tool2", "QTP"
oDict.Add "Tool3", "Silk Test"
Then it should look like
Key Value
Tool1 Selenium
Tool2 QTP
Tool3 Silk Test
To fetch the data from the Dict object we can use .Item method.
Msgbox oDict.item("Tool2") -- Should return respective item value i.e QTP
The problem with Dictionary object is, if you try to access any item which is not even
present in the Dictionary,it does not result in an error. Instead, the non-existent element
is added to the Dictionaty object.
Set oDict = CreateObject("Scripting.Dictionary")
oDict.Add "Tool1", "Selenium"
oDict.Add "Tool2", "QTP"
oDict.Add "Tool3", "Silk Test"
MsgBox oDict.Item("Tool4")
Here no ArrayIndexOutOfBoundsException occurs, rather than Tool4, is added to the Dictionary, along
with the item value Null.
Looping through the Items in Dictionary Object:
Dim oItem
Dim sItem, sMsg
Dim oDict
Set oDict = CreateObject("Scripting.Dictionary")
Set oDict = CreateObject("Scripting.Dictionary")
oDict.Add "Tool1", "Selenium"
oDict.Add "Tool2", "QTP"
oDict.Add "Tool3", "Silk Test"
For Each oItem In oDict
sItem = oDict.Item(oItem )
sMsg = sMsg & sItem & vbCrLf
Next
MsgBox sMsg
Dictionry object having only one configurable property, Compare Mode.
If its is created in binary mode, which means each key in the Dictionary is based on its ASCII value.
Means lowercase and upper cases are treated as different here.
When a Dictionary is configured in text mode, uppercase and lowercase letters are treated identically.
0 – Sets the mode to binary. This is the default value.
1 – Sets the mode to text.
Set oDict = CreateObject("Scripting.Dictionary")
oDict.CompareMode = 1
Initially while creating only youi can set the compare mode.Once it is alreday having any element, you
are not allowed
to change the compare mode.
To reconfigure the Dictionary mode, you first need to remove all items from the Dictionary.
To remove a value from a dictionary, use the .Remove method and specify the key to remove. For
example:
oDict.Remove “Tool2"
To remove all values and clear the dictionary, use the .RemoveAll method. Use the .Count property to
obtain a count of values in the dictionary.
The .Keys and .Items methods return an array containing all the keys or items from the dictionary. For
example:
aTools = oDict.Keys
aNames = oDict.Items

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (19)

Js objects
Js objectsJs objects
Js objects
 
Dynamic databinding
Dynamic databindingDynamic databinding
Dynamic databinding
 
Function Java Vector class
Function Java Vector classFunction Java Vector class
Function Java Vector class
 
Any Which Array But Loose
Any Which Array But LooseAny Which Array But Loose
Any Which Array But Loose
 
ознакомления с модулем Entity api
ознакомления с модулем Entity apiознакомления с модулем Entity api
ознакомления с модулем Entity api
 
Lecture 7
Lecture 7Lecture 7
Lecture 7
 
packaging procedures_and_state
packaging procedures_and_statepackaging procedures_and_state
packaging procedures_and_state
 
java object oriented presentation
java object oriented presentationjava object oriented presentation
java object oriented presentation
 
Iterator Design Pattern
Iterator Design PatternIterator Design Pattern
Iterator Design Pattern
 
Generics collections
Generics collectionsGenerics collections
Generics collections
 
mediator
mediatormediator
mediator
 
Lesson3
Lesson3Lesson3
Lesson3
 
Python Dictionary
Python DictionaryPython Dictionary
Python Dictionary
 
Javasession7
Javasession7Javasession7
Javasession7
 
Ts archiving
Ts   archivingTs   archiving
Ts archiving
 
Reversing JavaScript
Reversing JavaScriptReversing JavaScript
Reversing JavaScript
 
Joshua bloch effect java chapter 3
Joshua bloch effect java   chapter 3Joshua bloch effect java   chapter 3
Joshua bloch effect java chapter 3
 
Pi j3.4 data-structures
Pi j3.4 data-structuresPi j3.4 data-structures
Pi j3.4 data-structures
 
Java tutorial part 4
Java tutorial part 4Java tutorial part 4
Java tutorial part 4
 

Ähnlich wie Basics of dictionary object

descriptive programming
descriptive programmingdescriptive programming
descriptive programmingAnand Dhana
 
PYTHON OBJECTS - Copy.pptx
 PYTHON OBJECTS - Copy.pptx PYTHON OBJECTS - Copy.pptx
PYTHON OBJECTS - Copy.pptxsanchiganandhini
 
Javascript Objects Deep Dive
Javascript Objects Deep DiveJavascript Objects Deep Dive
Javascript Objects Deep DiveManish Jangir
 
Java: Objects and Object References
Java: Objects and Object ReferencesJava: Objects and Object References
Java: Objects and Object ReferencesTareq Hasan
 
Persistence And Documents
Persistence And DocumentsPersistence And Documents
Persistence And DocumentsSV.CO
 
Eqela Core API and Utilities
Eqela Core API and UtilitiesEqela Core API and Utilities
Eqela Core API and Utilitiesjobandesther
 
python full notes data types string and tuple
python full notes data types string and tuplepython full notes data types string and tuple
python full notes data types string and tupleSukhpreetSingh519414
 
Comparable/ Comparator
Comparable/ ComparatorComparable/ Comparator
Comparable/ ComparatorSean McElrath
 
Functional Core, Reactive Shell
Functional Core, Reactive ShellFunctional Core, Reactive Shell
Functional Core, Reactive ShellGiovanni Lodi
 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript ProgrammingSehwan Noh
 
Object oriented database concepts
Object oriented database conceptsObject oriented database concepts
Object oriented database conceptsTemesgenthanks
 
Cordova training : Day 4 - Advanced Javascript
Cordova training : Day 4 - Advanced JavascriptCordova training : Day 4 - Advanced Javascript
Cordova training : Day 4 - Advanced JavascriptBinu Paul
 
Chapter 14 Dictionary.pptx
Chapter 14 Dictionary.pptxChapter 14 Dictionary.pptx
Chapter 14 Dictionary.pptxjchandrasekhar3
 
Qtp training session IV
Qtp training session IVQtp training session IV
Qtp training session IVAisha Mazhar
 
It Is Possible to Do Object-Oriented Programming in Java
It Is Possible to Do Object-Oriented Programming in JavaIt Is Possible to Do Object-Oriented Programming in Java
It Is Possible to Do Object-Oriented Programming in JavaKevlin Henney
 
JavaScript Workshop
JavaScript WorkshopJavaScript Workshop
JavaScript WorkshopPamela Fox
 

Ähnlich wie Basics of dictionary object (20)

descriptive programming
descriptive programmingdescriptive programming
descriptive programming
 
PYTHON OBJECTS - Copy.pptx
 PYTHON OBJECTS - Copy.pptx PYTHON OBJECTS - Copy.pptx
PYTHON OBJECTS - Copy.pptx
 
Javascript Objects Deep Dive
Javascript Objects Deep DiveJavascript Objects Deep Dive
Javascript Objects Deep Dive
 
Java: Objects and Object References
Java: Objects and Object ReferencesJava: Objects and Object References
Java: Objects and Object References
 
Persistence And Documents
Persistence And DocumentsPersistence And Documents
Persistence And Documents
 
Eqela Core API and Utilities
Eqela Core API and UtilitiesEqela Core API and Utilities
Eqela Core API and Utilities
 
python full notes data types string and tuple
python full notes data types string and tuplepython full notes data types string and tuple
python full notes data types string and tuple
 
Comparable/ Comparator
Comparable/ ComparatorComparable/ Comparator
Comparable/ Comparator
 
Functional Core, Reactive Shell
Functional Core, Reactive ShellFunctional Core, Reactive Shell
Functional Core, Reactive Shell
 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript Programming
 
Object oriented database concepts
Object oriented database conceptsObject oriented database concepts
Object oriented database concepts
 
Cordova training : Day 4 - Advanced Javascript
Cordova training : Day 4 - Advanced JavascriptCordova training : Day 4 - Advanced Javascript
Cordova training : Day 4 - Advanced Javascript
 
Chapter 14 Dictionary.pptx
Chapter 14 Dictionary.pptxChapter 14 Dictionary.pptx
Chapter 14 Dictionary.pptx
 
Qtp training session IV
Qtp training session IVQtp training session IV
Qtp training session IV
 
It Is Possible to Do Object-Oriented Programming in Java
It Is Possible to Do Object-Oriented Programming in JavaIt Is Possible to Do Object-Oriented Programming in Java
It Is Possible to Do Object-Oriented Programming in Java
 
JavaScript Workshop
JavaScript WorkshopJavaScript Workshop
JavaScript Workshop
 
Introduction to js (cnt.)
Introduction to js (cnt.)Introduction to js (cnt.)
Introduction to js (cnt.)
 
jQuery
jQueryjQuery
jQuery
 
Dom
Dom Dom
Dom
 
Oop java
Oop javaOop java
Oop java
 

Kürzlich hochgeladen

Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmStan Meyer
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDhatriParmar
 
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Association for Project Management
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Projectjordimapav
 
Using Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea DevelopmentUsing Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea Developmentchesterberbo7
 
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQuiz Club NITW
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4JOYLYNSAMANIEGO
 
week 1 cookery 8 fourth - quarter .pptx
week 1 cookery 8  fourth  -  quarter .pptxweek 1 cookery 8  fourth  -  quarter .pptx
week 1 cookery 8 fourth - quarter .pptxJonalynLegaspi2
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdfMr Bounab Samir
 
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...DhatriParmar
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...DhatriParmar
 
Multi Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP ModuleMulti Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP ModuleCeline George
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17Celine George
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSMae Pangan
 
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQ-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQuiz Club NITW
 

Kürzlich hochgeladen (20)

Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and Film
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
 
Paradigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTAParadigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTA
 
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Project
 
Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"
 
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptxINCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
 
Using Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea DevelopmentUsing Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea Development
 
prashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Professionprashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Profession
 
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4
 
week 1 cookery 8 fourth - quarter .pptx
week 1 cookery 8  fourth  -  quarter .pptxweek 1 cookery 8  fourth  -  quarter .pptx
week 1 cookery 8 fourth - quarter .pptx
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdf
 
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
 
Multi Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP ModuleMulti Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP Module
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHS
 
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQ-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
 

Basics of dictionary object

  • 1. Dictionary Object In QTP : The Dictionary object is used to hold a set of data values in the form of (key, item) pairs. It is also known as 'Associative Array' because it associates a key with an item. If you compare it with an Array, Keys are similar to the indices in an array. But here Keys are not numetic Indices like we have in array ranther than these are arbitrary strings normally. Each key in a single Dictionary object must be unique. Dictionary Object is a part of VB Script and so it can be used with the tools supporting VBS. (Here we will talk how it used in QTP). Dictionary object is COM object(Component Object Model) and “Scripting.Dictionary” is the ProdID for Disctionary object. It can be instantiated as following: Dim oDict Set oDict = CreateObject("Scripting.Dictionary") Using Add method we can add fdifferent keya and pair values to the structure. Set oDict = CreateObject("Scripting.Dictionary") oDict.Add "Tool1", "Selenium" oDict.Add "Tool2", "QTP" oDict.Add "Tool3", "Silk Test" Then it should look like Key Value Tool1 Selenium Tool2 QTP Tool3 Silk Test To fetch the data from the Dict object we can use .Item method. Msgbox oDict.item("Tool2") -- Should return respective item value i.e QTP The problem with Dictionary object is, if you try to access any item which is not even present in the Dictionary,it does not result in an error. Instead, the non-existent element is added to the Dictionaty object. Set oDict = CreateObject("Scripting.Dictionary") oDict.Add "Tool1", "Selenium" oDict.Add "Tool2", "QTP" oDict.Add "Tool3", "Silk Test" MsgBox oDict.Item("Tool4")
  • 2. Here no ArrayIndexOutOfBoundsException occurs, rather than Tool4, is added to the Dictionary, along with the item value Null. Looping through the Items in Dictionary Object: Dim oItem Dim sItem, sMsg Dim oDict Set oDict = CreateObject("Scripting.Dictionary") Set oDict = CreateObject("Scripting.Dictionary") oDict.Add "Tool1", "Selenium" oDict.Add "Tool2", "QTP" oDict.Add "Tool3", "Silk Test" For Each oItem In oDict sItem = oDict.Item(oItem ) sMsg = sMsg & sItem & vbCrLf Next MsgBox sMsg Dictionry object having only one configurable property, Compare Mode. If its is created in binary mode, which means each key in the Dictionary is based on its ASCII value. Means lowercase and upper cases are treated as different here. When a Dictionary is configured in text mode, uppercase and lowercase letters are treated identically. 0 – Sets the mode to binary. This is the default value. 1 – Sets the mode to text. Set oDict = CreateObject("Scripting.Dictionary") oDict.CompareMode = 1 Initially while creating only youi can set the compare mode.Once it is alreday having any element, you are not allowed to change the compare mode. To reconfigure the Dictionary mode, you first need to remove all items from the Dictionary. To remove a value from a dictionary, use the .Remove method and specify the key to remove. For example: oDict.Remove “Tool2" To remove all values and clear the dictionary, use the .RemoveAll method. Use the .Count property to obtain a count of values in the dictionary.
  • 3. The .Keys and .Items methods return an array containing all the keys or items from the dictionary. For example: aTools = oDict.Keys aNames = oDict.Items