How to pass command line arguments (test data parameters) in Robot framework How to pass command line arguments (test data parameters) in Robot framework selenium selenium

How to pass command line arguments (test data parameters) in Robot framework


In the Robot Framework Userguide there is an entire chapter on Configuring the Execution of Robot Framework. In this chapter there is a section on passing variables via the command line.

An example:

robot --variable OS:Linux --variable IP:10.0.0.42 my_test_suite_file.robot

and then you can use the variables ${OS} and ${IP} at any point in your scripts as they are Global variables.


Add a variable with the target country, use it in the case, and set its value on run start. Only the relevant parts of your code:

# put this just after the end of the Settings section*** Variables ***${country}    USA*** Test Cases ***Sample Test Case To Create Data for Multiple countries     Select Country      ${country}    # the rest of your code

If your run it as is, it will use "USA" as value; if you want to override, pass the other value on the CLI:

 robot --variable country:Mexico your_file.robot


If you are using pybot command, use one of the bellow Syntaxes

pybot --variable Variable:Value ScriptName.txt

OR

pybot -v Variable:Value ScriptName.txt

Multiple Variable

pybot -v Variable1:Value -v Variable2:Value ScriptName.txt

You can access the command line variable value directly in your script without declaring and re-assigning.

Example.

pybot -v userId:admin -v password:123admin123 testLoginScript.txt