I could use the "TEST TEARDOWN" keyword in the header but this gets executed after each test case. Is there any way I can do in the code so that it only executes if the test case fails and if otherwise, skips?
The keyword Run Keyword If Test Failed was created for that case. Better have Robotframework documentation always at hand (and browse trough it at least once).
Here is a special note about it:
This keyword can only be used in a test teardown. Trying to use it anywhere else results in an error.