python - How to use extra arguments passed with Variable file - Robot framework -
in robot framework user guide there section describes how pass variable files , possible variables if needed.
example:
pybot --variablefile taking_arguments.py:arg1:arg2
my question can use these possible variables arg1 , arg2 in taking_arguments.py file afterwards , if can how?
right have this:
pybot --variablefile taking_arguments.py:arg1:arg2
taking_arguments.py contents:
ip_prefix = arg1
but results in
nameerror: name 'arg1' not defined
the way use variables in argument file using --variablefile filename.py:arg1:arg2
syntax have variable file implement function get_variables
. function passed arguments specify on command line, , must return dictionary of variable names , values.
for example, consider following variable file, named "variables.py":
def get_variables(arg1, arg2): variables = {"argument 1": arg1, "argument 2": arg2, } return variables
this file creates 2 robot variables, named ${argument 1}
, ${argument 2}
. values these variables values of arguments passed in. might use variable file this:
pybot --variablefile variables.py:one:two ...
in case, strings "one" , "two" passed get_variables
2 arguments. these associated 2 variables, resulting in ${argument 1}
being set one
, ${argument 2}
being set two
.
Comments
Post a Comment