How to set a robot framework variable to a boolean value?

5,938 views
Skip to first unread message

ubr...@gmail.com

unread,
Apr 6, 2021, 9:53:55 AM4/6/21
to robotframework-users
Hi,

    Can someone show me the proper syntax of boolean value in robot framework?   I have the following line the robot file and it does not appear to be working for me.

               ${continueFlag}=       Convert to boolean         False

If you think the line is working, can you show me how to print out the value of variable ${continueFlag}?  The document is not helpful and refers/defers  to python bool() function.

Thank you,

Lawrence

Deepesh Som

unread,
Apr 6, 2021, 10:07:27 AM4/6/21
to ubr...@gmail.com, robotframework-users
U can use:


Set Test Variable  ${continueFlag}  ${False}

This will also be recognised as boolean in python file directly if u try to fetch the variable value and compare in condition eg
'''
continueFlag= BuiltIn().get_variable_value("${continueFlag")
if continueFlag:
    print("value is True")
'''

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/robotframework-users/e2e26b20-0c7e-40da-b74e-85d6a95adc76n%40googlegroups.com.

Deepesh Som

unread,
Apr 6, 2021, 10:12:33 AM4/6/21
to ubr...@gmail.com, robotframework-users
Correcting the typing errors:

Set Test Variable  ${continueFlag}  ${False}

This will also be recognised as boolean in python file directly if u try to fetch the variable value and compare in condition eg
'''
continueFlag= BuiltIn().get_variable_value("${continueFlag}")
if continueFlag:
    print("value is True")
'''

Note: the key is to use ${False} as pure boolean value in robot framework,

Lawrence Lee

unread,
Apr 6, 2021, 2:51:43 PM4/6/21
to Deepesh Som, robotframework-users, ubrmax
Hi Deepesh,

     Thank you for your information and example. It's helpful.

     As an uninitiated robot framework user, the way that the boolean value was represented as a variable throws me a curve in addition to the skimmy robot framework documentation on this simple topic. 

     I'll keep this email for my reference as one of probable robot framework idiosyncrasy features.

Regards,

Lawrence
Reply all
Reply to author
Forward
0 new messages