cancel
Showing results for 
Search instead for 
Did you mean: 

Adding dictionary object to project variables

SOLVED
sriram_sig
Contributor

Adding dictionary object to project variables

i have a requirement to automate a web project and i fould it to be easier to work with xpath rather than the properties in name mapping. So i thought of adding the variable name and xpath like a key-value pair in a dictionary object.Is there a way by which i can add this dictonary object to project variables.?

when i execute the below code i get a type mismatch error in the last line

d = Sys.OleObject["Scripting.Dictionary"]

d.Add("a", "Alphabet")
d.Add("b", "Book")
d.Add("c", "Coffee")
Project.Variables.AddVariable(d,"Object")
1 ACCEPTED SOLUTION

Accepted Solutions
tristaanogre
Community Hero

Re: Adding dictionary object to project variables

The first parametre of "AddVariable" is the name of the variable

 

Change your code to 

 

d = Sys.OleObject["Scripting.Dictionary"]

d.Add("a", "Alphabet")
d.Add("b", "Book")
d.Add("c", "Coffee")
Project.Variables.AddVariable("Dictionary", "Object")
Project.Variables.Dictionary = d;

Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

View solution in original post

2 REPLIES 2
tristaanogre
Community Hero

Re: Adding dictionary object to project variables

The first parametre of "AddVariable" is the name of the variable

 

Change your code to 

 

d = Sys.OleObject["Scripting.Dictionary"]

d.Add("a", "Alphabet")
d.Add("b", "Book")
d.Add("c", "Coffee")
Project.Variables.AddVariable("Dictionary", "Object")
Project.Variables.Dictionary = d;

Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

View solution in original post

sriram_sig
Contributor

Re: Adding dictionary object to project variables

Thank you, works perfectly fine

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors