[英]Robot Framework - query returned keyword types
is there a means of querying the returned keyword variable types? 有没有一种查询返回的关键字变量类型的方法? Trying to debug some scripts and would be really useful to have something like the Python
type(my_variable)
available? 尝试调试一些脚本,是否有可用的类似Python
type(my_variable)
东西真的有用吗?
Assuming you are using robot version 2.9 or above, you can use the Evaluate keyword to use python's type(myvariable)
by taking advantage of Evaluate's variable substitution : 假设您使用的机器人版本为2.9或更高版本,则可以利用Evaluate的变量替换功能来使用Evaluate关键字来使用python的
type(myvariable)
:
For example: 例如:
*** Keywords ***
keyword that returns an int
${result}= set variable ${42}
[return] ${result}
keyword that returns a list
${result}= create list one two three
[return] ${result}
keyword that returns a string
${result}= set variable foo
[return] ${result}
*** Test Cases ***
Example
${result1}= keyword that returns an int
@{result2}= keyword that returns a list
${result3}= keyword that returns a string
${type1}= evaluate type($result1)
${type2}= evaluate type($result2)
${type3}= evaluate type($result3)
should be equal as strings ${type1} <type 'int'>
should be equal as strings ${type2} <type 'list'>
should be equal as strings ${type3} <type 'unicode'>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.