如何在机器人框架中将列表作为命令行参数传递.? [英] How to pass a list as command line argument in robot framework.?
问题描述
我正在尝试使用 -v 选项将列表作为命令行参数传递给机器人脚本.由于这不是直接支持的,我正在尝试一些解决方法,如
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
这部分完成了工作,因为当我将它们登录到控制台时,我可以看到空格分隔的值.喜欢a b c
.但是我无法使用 FOR 迭代所有列表成员.我只看到一个项目(a b c")正在迭代.
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.?
推荐答案
虽然我不太喜欢它,但我能够从 String 遍历
库.Split String
创建的列表
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 "来自 CLI 的变量列表" .
这篇关于如何在机器人框架中将列表作为命令行参数传递.?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!