How to Create a Dictionary Variable

6,118 views
Skip to first unread message

Bill

unread,
Oct 26, 2010, 2:47:29 PM10/26/10
to robotframework-users
Hi All,

I am new to RF and I am having trouble creating a dictionary variable
in my test text file.

I have attemped the following in the Variable Table

| ${D} | Create Dictionary | a | one | b | two

I get a warning, but it does not actually create a dictionary.

Any help is greatly appreciated.

Thank you,

Bill Brothers

Pekka Klärck

unread,
Oct 26, 2010, 4:23:08 PM10/26/10
to bbro...@internap.com, robotframework-users
2010/10/26 Bill <bbro...@internap.com>:

>
> I am new to RF and I am having trouble creating a dictionary variable
> in my test text file.
>
> I have attemped the following in the Variable Table
>
> | ${D} | Create Dictionary | a | one | b | two
>
> I get a warning, but it does not actually create a dictionary.

Unfortunately it is not possible to create variables in the variable
table using keyword return values. You can only create scalar
variables containing strings and list variables:

***Variables***
| ${STRING} | The value |
| @{LIST} | first item | second | third |

You can create dictionaries and other objects from keyword return
values inside test cases and keywords. If you need to make them
available for other tests in that suite similarly as variables in the
variable table, you can use `Set Suite Variable` keyword for that. An
alternative solution is using variables files which allow you to
create all kind of variables dynamically.

All these options are explained pretty thoroughly in the User Guide.
I'd normally give you direct links but I'm somewhat busy at the
moment...

Cheers,
.peke
--
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org

Pekka Klärck

unread,
Aug 4, 2011, 6:06:52 PM8/4/11
to sunny, robotframework-users
[Replying back to robotframework-users. In the future please send
questions there and not to me directly.]

2011/8/5 sunny <oop...@gmail.com>:
> Using RF Test Case, how do I pass a list of tuples that contain
> keywords (key, value) as arguments ?
>
> def createProfile(*args, **kwargs):
>    ...do something

Robot Framework doesn't support using Python's keyword arguments.

> I'm using python/Netbeans and it works fine by calling
>
> a = {'id':2,  'name':'jane', 'symbol':'pic1.png'}
> b = {'id':22, 'name':'jim', 'symbol':'pic2.png'}
>
> createProfile(a, b)

In this case you aren't actually using keyword arguments either but
instead 'args' will have value (a, b). To use kwargs you needed to use
e.g. createProfile(a, **b).

Reply all
Reply to author
Forward
0 new messages