Forum Discussion

sriram_sig's avatar
sriram_sig
Contributor
6 years ago

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")
  • 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;
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    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;