--- Markdown ---
## Or how to avoid a 400mb log.html file
When you experience a failure in Robot Framework with the browser, having a screenshot of the point of failure is great for debugging. The problem comes when you are expecting a failure and you want to simply ignore it and move on.
For example, if I expect a keyword to fail occasionally, and it doesn't harm my job process, I may choose to use the keyword `Run Keyword and Ignore Error` which will happily ignore any errors. Now this may not be the best practice for a bot, but there are some cases which are unavoidable (that's for another article).
The problem is when you use this in conjunction with Selenium. Regardless of your ignoring the error, Selenium will go ahead and take a screenshot of the process. This may not seem like such a big issue, but if this is in a loop and happening hundreds of times, your log.html file will quickly grow to an unmanageable size.
## Keep the screenshots you want, but not the ones you don't
You still want to have Selenium take a screenshot on failure, but only on failures that you haven't specifically ignored. Here's how to do it.
First remove keyword registered to run on a failure:
```bash
Open Browser
# Perform tasks to open the browser
Register Keyword To Run On Failure NONE
```
Then we still need to ensure that we get a screenshot on TEST FAILURE (emphasis mine):
```bash
Teardown
Run Keyword If Test Failed Capture Page Screenshot
```
## Isn't this the same thing
The reason this is confusing is that it looks like you've merely deleted the screenshot action and replaced it with the same action. But in reality they are two different callbacks. The first one happens on every failure, regardless of if the test failed. In our case the keyword fails, but it ignores it and keeps the tests passing. However if the tests are failing (not just a keyword run) then we go ahead and take the screenshot.
It's pretty simple, but hopefully this saves someone a little time when they run into a log.html file that seem ridiculously large.