user3170122 user3170122 -4 years ago 172
Python Question

How to pass a list as command line argument in robot framework.?

I am trying to pass a list as a command line argument to a robot script using -v option. Since this is not directly supported i am trying some workaround like,

robot -v list_arg:a__b__c -E space:_ sample.robot


This partly does the job as i can see space separated values when i log them onto console. Like

a b c
.
However i am unable to iterate over all the list members using FOR.I only see one item("a b c") being iterated.

Is there any other elegant way to pass Lists via command line in robot framework.?

Answer Source

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" .

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download