DEV Community

Cover image for Robot Framework: Pass Boolean variables from command line
Laura Ojala
Laura Ojala

Posted on • Updated on

Robot Framework: Pass Boolean variables from command line

I am often googling how to pass Boolean Command Line arguments in the Robot Framework when starting tests. The answer is: True and False work (case is important here as this is Python).

In some earlier releases, 0 and 1 were seen as Boolean but that does not apply in the newer Robot Framework versions.

Example, passing CLI (Command Line Interface) variables

Below is an example that tests that variable MY_BOOLEAN is Boolean type (so tests pass both with True and False).

I wanted to play with the new Python Inline Evaluation (see User Guide here) so the example has another test that uses that (both tests test exactly the same thing, the only difference is the syntax):

And to start that test, MY_BOOLEAN is given using --variable notation:

robot --variable MY_BOOLEAN:False path/to/tests/
Enter fullscreen mode Exit fullscreen mode

Or, in a shorter form using -v:

robot -v MY_BOOLEAN:True path/to/tests/
Enter fullscreen mode Exit fullscreen mode

Closing words

Next time when I google "robot framework how to pass boolean command line arguments" I hopefully pop into this blog post 🤓. Maybe this post might also help with the concept of passing Robot Framework variables from the command line.

ps. Passing multiple arguments is done by adding multiple -v "blocks":

robot -v MY_VARIABLE:cat -v SOME_OTHER_VARIABLE:dog path/to/tests/
Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Collapse
 
ozyalhan profile image
Ozgur Alhan

It's good point to start, thanks