Arun
Arun

Reputation: 35

How to use Listeners in robot framework

Im using python 2.7.15 with robot versuon 3.0.4. I have a requirement to take only the screenshots of FAILED test cases. Some posts in stackoverflow says listeners must be used for manipulating test results. or is there a keyword for the same?

Upvotes: 0

Views: 1539

Answers (1)

Lubos Jerabek
Lubos Jerabek

Reputation: 833

Not sure what you're after but this is what I use at RF level:

Global Test Teardown
    Run Keyword If Test Failed    Capture Page Screenshot

Alternatively you should be able to do something like this in Python:

def global_test_teardown(testStatus=BuiltIn().get_variable_value("${TEST STATUS}")):
    seleniumlib = BuiltIn().get_library_instance('SeleniumLibrary')
    if testStatus=="FAIL":
        seleniumlib.capture_page_screenshot()

Upvotes: 1

Related Questions