0
votes

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

2

2 Answers

3
votes

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

1
votes

Mind your spaces after keywords

Set To Dictionary      ${Data Provider}     name     Sujit