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?
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 :
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'>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.