Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getting error while using Set To Dictionary keyword in robot framework

Getting error while using Set To Dictionary keyword in robot framework

Code:

  Set To Dictionary ${Data Provider}    name    Sujit

I am getting following error while using Set To Dictionary Keyword

TypeError: 'str' object does not support item assignment

like image 295
Sujit Patil Avatar asked Apr 24 '26 23:04

Sujit Patil


1 Answers

Your ${Data Provider} variable needs to be a dictionary, not a string. Provided that you've imported the Collections library, you can declare a dictionary with the Create Dictionary keyword.

Example:

${Data Provider}    Create Dictionary
Set To Dictionary   ${Data Provider}    name    Sujit
Log                 ${Data Provider}

You can also initialise a dictionary with values directly:

${Data Provider}    Create Dictionary   name    Sujit
Log                 ${Data Provider}

Both of these examples would log INFO : ${Data Provider} = {u'name': u'Sujit'}. Find more information about the Collections library here: http://robotframework.googlecode.com/hg/doc/libraries/Collections.html?r=2.8.5

like image 102
asemahle Avatar answered Apr 30 '26 11:04

asemahle



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!