I know we can write a listener to run the keyword when there is a failure in the keyword by checking the status of the keyword in the listener. But one of my requirements apart from looking at the Status, I want to look at the error message also before I run the keyword.
RunListner.py
def _end_keyword(self, name, attributes):
if attributes['status'] == 'FAIL':
The above portion of code in the listeners will help me to check the status of Keyword, but no way I can check the reason for the failure of the keyword. Is there something like this possible?
def _end_keyword(self, name, attributes):
if attributes['status'] == 'FAIL' and ErrorMessage==""something went wrong"" :
At present I don't have idea how to pass on the error information to listner .
RobotCode
*** Settings ***
Documentation Suite description
Library RunListner
Test Template Run Keyword And Ignore Error
Suite Setup Set Keyword To Run On Failure Log Many 1 2 3
*** Test Cases ***
Test title
log step one
log step two
fail something went wrong
fail something else went wrong
log last step
As you can see in the screenshot the failure reason is "something went wrong" is one of failure and the other is "Something else went wrong". I want to call listener only when "something went wrong"
