问题
I hope you can help me, I am quite stuck with this issue :(
I am trying to create all the tests using the robot api with python, I followed the example in the documentation, but I need to capture the output from a keyword and I dont find how can I do it
I tried as usual in rf-ride syntax:
test.keywords.create('${greps}= grep file', args=['log.txt', 'url:', 'encoding_errors=ignore'])
It says: No keyword with name '${grep}= grep file' found.
I tried:
output = test.keywords.create('grep file', args=['log.txt', 'url:', 'encoding_errors=ignore'])
but the variable output is having just the keyword name, not the output from kw
I dont know where to look for more info, all the examples are creating kw which dont return any value...
回答1:
The call to test.keywords.create(...)
doesn't call the keyword, it merely creates one to be called later. If you want the results to be assigned to a variable, use the assign
attribute when calling create
. This argument takes a list of variable names.
For example, given this line in plain text format:
${greps}= grep file log.txt url: encoding_errors=ignore
... you would create it like this using the API:
test.keywords.create('grep file',
args=['log.txt', 'url:', 'encoding_errors=ignore'],
assign=['${greps}'])
来源:https://stackoverflow.com/questions/38973452/how-to-get-the-output-from-a-kyword-using-robot-api