Get Type in Robot Framework
17,279
Solution 1
This is what I use:
${type} = Evaluate type($temp).__name__
Note: it's good to have global string/int/float/list/dict/... examples for comparison than hard-coding the type values as they might differ depending on build.
Solution 2
You can do e.g. this:
${type_ABC} Evaluate type($ABC)
Author by
Bell Aimsaard
Updated on June 22, 2022Comments
-
Bell Aimsaard almost 2 years
Could you tell me about how to get the variable type in Robot Framework.
${ABC} Set Variable Test ${XYZ} Set Variable 1233
Remark: Get the variable Type such as string, int
get ${ABC} type = string
get ${XYZ} type = int
-
Jan Kovařík about 7 yearsDid you consider to accept/upvote the answer if it was useful for you? Of course you can try to wait for better one :)
-
Russell Smith about 7 yearsDid you actually try your own example? I think the answer might surprise you for
${XYZ}
-
Jan Kovařík about 7 yearsYes, I tried. It gives also 'str' as for ${ABC}. If you assign to ${XYZ} e.g.
Evaluate 1233
, you'll get 'int'. Am I wrong? I'll be more than happy if you could provide deeper explanation. -
A. Kootstra about 7 yearsIf you want to ensure that a variable is set as a Integer there is a different way of assigning it:
${XYZ} Set Variable ${1233}
note the${1233}
will then result into a different log entry:INFO : ${type_XYZ} = <type 'int'>
-
Jan Kovařík about 7 yearsThanks @A.Kootstra