jollyRoger
jollyRoger

Reputation: 68

Robotframework + Selenium2Library Native Py Keyword Run_on_failure

I'm having some issues with getting selenium2library to trigger run on failure when using a custom robotframework keyword.

I wrote a keyword in python that is working as I expect with the exception that upon failure when I raise an AssertionError, the Run_On_Failure keyword for Selenium2Library isn't being called.

I've also tried wrapping this keyword in a user defined Robotframework keyword and I still can't get Run_On_Failure to trigger. Yet, when I cause a S2L keyword to fail, the Run_On_Failure kicks in as I would expect.

I need Run_On_Failure to be called when my RFpy keyword fails. Anyone have any advice?

Here is my keyword

    def compare_text(self, actualString, expectedString):
    """Compares two strings of text, this differs from the Selenium2Library
    text compare routines because we do not require an element locator, just
    the `actual` and `expected` strings.  String matching failure will cause
    the test to Assert an error and the test to fail.
    """
    print("Actual Here: %s") % (actualString)
    print("Expected Here: %s") % (expectedString)
    if actualString != expectedString:
        raise AssertionError("ERROR: Actual and Expected strings don't match!")

Upvotes: 0

Views: 553

Answers (1)

jollyRoger
jollyRoger

Reputation: 68

The solution is a built-in RF keyword called "Run keyword if test failed".

Upvotes: 1

Related Questions