I’m trying to create a DICT of LISTs, but not getting the sigils and syntax right yet. For example a DICT of FRIENDS, with each element being a CITY with a list of friends in it.
friends = {
'brescia': ["Marco", "Davide"],
'albany': ['Willie', 'Jim'],
'st marys': ['Kenn'],
'maryland': ['Pat and Patrick', 'Shannon'],
}
city = 'brescia'
for friend in friends[city]:
print(friend)
So this would print “Davide” and “Marco”. How do I do that in RobotFramework?
Global idea would be this, having the lists built then included in the Dict:
VAR @{brescia} Marco Davide
VAR @{albany} Willie Jim
VAR @{st marys} Kenn
VAR @{maryland} Pat and Patrick Shannon
VAR &{friends} brescia=${brescia} albany=${albany} st marys=${st marys} maryland=${maryland}
VAR ${city} brescia
FOR ${friend} IN @{friends}[${city}]
Log ${friend}
END
If for some reason, you don’t want to pre-define the lists first, you can use Inline Python evaluation as well:
*** Test Cases ***
Test Case 1
VAR &{friends}
... brescia=${{["Marco", "Davide"]}}
... albany=${{['Willie', 'Jim']}}
... st marys=${{['Kenn']}}
... maryland=${{['Pat and Patrick', 'Shannon']}}
VAR ${city} brescia
FOR ${friend} IN @{friends}[${city}]
Log To Console ${friend}
END