So, {} represents a dictionary,
e.g.
{'key': value}
and we can get a value out of a Robot Framework dictionary via
${dictionary}['key']
One would assume you could then go
${dictionary}['key']= Set Variable Hello World
but no, this will not set the value; we are not referencing an object in a dictionary, but trying to set a variable of a string, which confuses Robot.
What existing keywords exist for this?
Well I was surprised to find no built in RFW keyword for setting. There is after all a
Get From Dictionary ${dictionary} ${key}
[Return] ${value}
After messing around, I realised it would take a fraction of the time to create a Python keyword. And this brings me to my recommended solution.
def update_in_dictionary(selfself, dictionary, key, newValue):
"""
Updates a value in a dictionary. Returns the dctionary
"""
dictionary[key]=newValue
return dictionary
QED.
A blog following the arduous journey along test paths and details of the interesting, bizarre and inane encountered en route.
Monday, 22 June 2015
Tuesday, 27 January 2015
Times are a changin'
One year elapsed with zero blog posts, and QTP is essentially dead. 2014 was quite a good year then, just not for my skill group. Lol.
Subscribe to:
Comments (Atom)
Robot Framework, Basic Setup
Plug: Robot Framework is quick to setup, easy to write tests for, and super fast to triage failures in. The last point really sets it apart...
-
So, {} represents a dictionary, e.g. {'key': value} and we can get a value out of a Robot Framework dictionary via ${dictionar...
-
For those short on time the most significant material is in black . Elaborated this becomes Hewlett Packard’s Quality Centre eleven ...
-
The art of testing lies in the ability to put the right checks in the right places to provide the right people with information at the right...