Home > Net >  Error converting a list of variables to INT in Robot Framework
Error converting a list of variables to INT in Robot Framework

Time:01-06

hello!

Is it possible in Robot Framework to create a list and the variables to be of type INT or NUMBER?

I tried in the form, but without success...

Attempt 1

${TEST_1}    Create List    01    61
${TEST_1}    Convert To Integer    ${TEST_1}
Set Suite Variable    ${TEST_1}

Attempt 2

@{TEST_2}    Replace Variables    0    9
@{TEST_2}    Convert To Integer    @{TEST_2}
Set Suite Variable    ${TEST_2}

Errors already displayed on attempts:

'None' cannot be converted to an integer: TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'

'01' cannot be converted to an integer: ValueError: int() base must be >= 2 and <= 36, or 0

can anybody help me?

Thanks very much!!

CodePudding user response:

The robot framework user guide describes number variables which are a way to define integers and floating point numbers.

The syntax is to simply wrap the number in ${}. For example, ${1} represents the integer , and ${3.14}represents the floating point number3.14`. You can also define values with octal, hex, binary, and scientific notation.

Using your code as an example, you can create a list of integers like this:

${TEST_1}    Create List    ${1}    ${61}
  • Related