davey_dev davey_dev - 14 days ago 5
Python Question

RobotFramework Create Dictionary with an integer value instead of string

Create Dictionary sensor_id=1


when using Python gives me:

{'sensor_id': '1'}


Where really I want:

{'sensor_id': 1}


Is there anyway to prevent the robot framework from adding these quotes to my integer values?

Answer

In robot, you can coerce a string to an integer by putting it inside ${}

${foo}=  create dictionary    sensor_id=${1}

With the above, the value in the dictionary will be an integer.

For more information see Number Variables in the robot framework user guide.