With Robot Framework 4.0 is it possible to get values in and out from .body into python script and from python script into .body test suite?

Viewed 180
bot.body.create_keyword('Create List', args=['a', 'b', 'c'], assign=['@{list}'])
bot.body.create_for(flavor='IN', variables=['${x}'], values=['@{list}'])
bot.body.create_keyword('log', args=['${x}'])

How to get value @list out of this keyword and into python script but without creating new keyword in another python script. example like this:

list = bot.body.create_keyword('Create List', args=['a', 'b', 'c'], assign=['@{list}'])
print(list) # and this will print in console and not in output.xml and in the order of execution 
1 Answers

I am afraid you cannot do this. The problem is that you are creating a test case programmatically, you just define a step Create List but it is not executed at that point, so the list is not created, there is no execution context.

The create_keyword function returns the keyword object not the return value of the inner Robot Framework keyword. Again that is not executed here, the list will be created when you call the suite.run().

You could try with a listener maybe or Log To Console but both of these will be invoked during execution as well.

Related