Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Type in Robot Framework

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

like image 986
Bell Aimsaard Avatar asked Mar 06 '17 05:03

Bell Aimsaard


People also ask

How do you get the type of variable in Robot Framework?

By default all variables created with Set Variable are strings - if you typed ${variable} Set Variable 123 , the type of that variable is going to be string - a string with the value "123", which though looks like a number is really a string (you can do Fetch From Left on it, for example).

Which variable type is allowed in the Robot Framework?

There are three types of variables supported in robot framework − scalar, list and dictionary.

How do you call a keyword in Robot Framework?

Enter the argument to be used with the keyword. Go back to your test case. Now, you need to pass the value which is the URL to be used for the test case. In the test case, when you type the user-defined keyword and press Ctrl + Spacebar, it gives the details of the keyword along with the arguments.

How do I get the current keyword in Robot Framework?

There is no support in robot for getting the current keyword name. Since the code you're writing must be run from a keyword, your keyword should know what its own name is.


2 Answers

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.

like image 61
Lubos Jerabek Avatar answered Oct 11 '22 07:10

Lubos Jerabek


You can do e.g. this: ${type_ABC} Evaluate type($ABC)

like image 32
Jan Kovařík Avatar answered Oct 11 '22 07:10

Jan Kovařík