2015-07-03 11:48 GMT+03:00 Nesat Ufuk <
nes...@gmail.com>:
>
> I have been using robot framework 2.9b1 for two day and new dictionary
> &{dict} variable type is saved my time.
Great to hear this new feature is useful!
> My question is how to access a sub dictionary item (in my case
> '1':'Example') like below.
>
> &{data}={'sale_data' :
> {'submerchantname' : 'submerchant',
> 'subfield1':
> {'mddFields' :
> {'1': 'Example',
> '2': 'two',
> '3': 'three',
> '9': 'nine'}
> },
> 'payment_methods' : 'credit'
> }
> }
>
> I have tried &{data.1} or &{data.sale_data.subfield1.mddFields.1} but those
> did not work.
The problem is not with nested dictionaries, they work just like you tried.
This dot-access uses Python's attribute access and attribute names
must be valid Python identifiers. Such an identifier cannot start with
a number and thus `mddFields.1` doesn't work. If you cannot rename the
key, you can switch to accessing values like `&{mddFields}[1]`.
Cheers,
.peke
--
Agile Tester/Developer/Consultant ::
http://eliga.fi
Lead Developer of Robot Framework ::
http://robotframework.org