Search code examples
python-3.xrobotframework

Robot Framework - Use Listener to interrupt Execution


I'm currently implementing a way to manage execution of a test in robot framework using using tkinter and the builtin listeners. I was able to make a Pause/Resume system relatively easily but I'm unable to make a Stop system.

In the RobotFramework UserGuide there is an example to insert keywords in test cases like this:

ROBOT_LISTENER_API_VERSION = 3

def start_test(test, result):
    test.keywords.create(name='Log', args=['Keyword added by listener!'])

The issue is, that this is deprecated and doesn't work. I have the following error when trying to use this : UserWarning: 'keywords' attribute is read-only and deprecated since Robot Framework 4.0. Use 'body', 'setup' or 'teardown' instead.

I don't know how to use Body setup or teardown to do what I want and I was unable to found any example similar to the deprecated one


Solution

  • Apparently I needed to ask the solution to find one by myself

    So I just needed to make something like this :

    test.setup.config(name="Fatal Error", args=["Force Quit"])
    

    or

    test.teardown.config(name="Fatal Error", args=["Force Quit"])