-
Notifications
You must be signed in to change notification settings - Fork 783
Description
There seems to be an issue with the implementation of the "Register keyword to run on failure" keyword. The keyword returns the value of the previously registered keyword which works fine if this is set to a keyword e.g. "Capture Page Screenshot" but if the registered keyword is set to "None" the return value is the string "No keyword". If you then try to use the return value "No keyword" and pass this back into "Register keyword to run on failure" a warning is generated:
"Keyword 'No keyword' could not be run on failure: No keyword with name 'No keyword' found."
I guess this keyword should either be returning "Nothing" as a string rather than "No keyword" to be consistent with the current way of disabling the run-on-failure functionality or it could return None instead
Example test case (simplistic example):
*** Settings ***
Library Selenium2Library
*** Test Cases ***
Test Case 1
${previous_kw}= Register Keyword To Run On Failure Nothing
${previous_kw}= Register Keyword To Run On Failure Capture Page Screenshot
Register Keyword To Run On Failure ${previous_kw}
Open Browser http://www.google.com
Page Should Contain invalid_string
The implementation could be changed to the following which would return None from line 2 of the above test case and no warnings are observed on failure:
def register_keyword_to_run_on_failure(self, keyword):
"""Documentation here....
"""
old_keyword = self._run_on_failure_keyword
old_keyword_text = old_keyword if old_keyword is not None else "No keyword"
if keyword:
new_keyword = keyword if keyword.strip().lower() != "nothing" else None
else:
new_keyword = None
new_keyword_text = new_keyword if new_keyword is not None else "No keyword"
self._run_on_failure_keyword = new_keyword
self._info('%s will be run on failure.' % new_keyword_text)
return old_keyword