Cortex
Cortex

Reputation: 684

Is it possible in Robot Framework to define a list in a dictionary?

I want to have a list in a dictionary, example:

The dictionary data has to entries: name and modes. modes should be a list that I can later access using ${data.modes}. Here's what I tried:

&{data}           name=Jeff    modes=['online', 'offline']

Calling modes retrieves a string. I tested it by getting the index of the element online, which returned 2 while it should be 0.

Is saving a list in a dictionary possible?

Upvotes: 0

Views: 565

Answers (2)

Todor Minakov
Todor Minakov

Reputation: 20067

What Bryan Oakley said, or the old-fashioned way - set as a value any list variable you have defined already:

@{my list}      online    offline
&{data}         name=Jeff    modes=${my list}

Upvotes: 1

Bryan Oakley
Bryan Oakley

Reputation: 386020

Starting with robot 3.2 you can use inline python evaluation, which lets you put almost any code between ${{ and }}:

&{data}    name=Jeff  modes=${{ ['online', 'offline'] }}

Upvotes: 1

Related Questions