How To Pass A List As Command Line Argument In Robot Framework.?
Solution 1:
Although I don't like it much, I was able to iterate through the list created by Split String from String library.
*** Settings ***
Library String
*** Test Cases ***
List Of Variables From CLI
@{list_of_vars} Split String ${my_vars}
:FOR ${var} IN @{list_of_vars}
\ Log ${var} WARN
robot -v my_vars:1_2 -E space:_ -t "List Of Variables From CLI" .
Solution 2:
When passing data structures to Robot Framework using Variable Files would probably be a better option considering you're already converting one structure into a command line compatible one. Adding a variable file uses the -V c:/path/to/file.ext syntax.
There are roughly two approaches:
Static: this is a text file containing the variable structures you seek. This can be in two formats:
- Python: declare the variable structures using regular Python syntax variable syntax
- YAML: using the YAML syntax it is possble to create Robot Framwork lists, dictionaries and strings.
Dynamic: in this scenario the Robot variables are generated and returned by Python code:
- Simple Python Function: using the
get_variables(arg)function is the simplest way of returning a dynamic number of variables or a dynamic structure of data. - Dynamic Python Class: using a variable class it's possible to hide certain variables, have a fixed set of variables that are complemented by
init()based on given input or have all of them generated dynamically.
- Simple Python Function: using the
In most cases the yaml structure is a good way of providing clean way of writing and maintaining an input file:
string: Hello, world!
integer: 42
list:
- one
- two
dict:
one: yksi
two: kaksi
original: &org
item1: foo
item2: bar
reference
org: *org
Post a Comment for "How To Pass A List As Command Line Argument In Robot Framework.?"