How to Take Screenshots and Exceptions
Understand why the TestNG listeners are a better way of capturing screenshots and logs.
We'll cover the following
A good test automation solution includes more than just test and page object classes. It should have support for collecting debugging information if any test fails. This means taking screenshots, collecting exceptions and stack traces, and saving them to a log file.
Do not take screenshots/logs in test methods
It is a bad idea to take screenshots and collect exceptions/stack traces with try/catch
statements in the test method as it leads to code duplication:
Get hands-on with 1400+ tech skills courses.