We use Robot Framework and SeleniumLibrary for most of our testing. Recently we started exploring using python more specially for building more complex keywords. We noticed that when these keywords fail, even when they fail when calling SeleniumLibrary keywords, they do not log screenshots.
As an example:
When implemented with Robot Framework:
The logging still happens but no screenshot is taken at failure. Reading through the code, it seems the handler in SeleniumLibrary doesn’t trigger since it’s not technically a SeleniumLibrary keyword that failed. Any ideas on how we can still get screenshots on failure even when calling SeleniumLibrary keywords in a python library?
Run on failure functionally is built by using Robot Framework dynamic library API. Therefore if you directly call methods implementing keywords, you are bypassing this feature and you need to implement this by yourself. Luckily it’s easy to do, example by using Python decorator Decorators in Python - GeeksforGeeks