[英]How to define a variable being a dictionary with list values in Robot Framework
[英]Robot Framework: How to know that variable is list, dictionary or regular
我需要从一个 Keyword 处理几种类型的数据 - 这将根据定义的数据类型调用另一个必要的 Keyword。
使用Evaluate type()
对列表和字典很有用,但当我们只有一个没有引号的字符串时会失败。 如果我添加引号 - 数据将始终被定义为字符串 - 即使它在列表或字典中。
例如
${list}= Create List 1 two
${type_list}= Evaluate type(${list})
# returns <type 'list'>
${dict}= Create Dictionary first=1 second=two
${type_dict}= Evaluate type(${dict})
# returns <type 'dict'>
${string}= Set Variable withoutQuotes
${type_string}= Evaluate type(${string})
# FAILS with:
Evaluating expression 'type(withoutQuotes)' failed: NameError: name 'withoutQuotes' is not defined
您能否推荐一些方法来定义不会失败的变量类型?
运行关键字和返回状态对我有帮助!
${passed}= Run Keyword And Return Status Evaluate type(${value})
${type}= Run Keyword If ${passed} Evaluate type(${value})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.