Where should screenshot-on-failure code live?
QuizEasy-MediumAsked in: Accenture, Infosys, TCS, Wipro
Where is the best place for the code that takes a screenshot when a test fails?
- In one central place that sees every result: a TestNG listener, a pytest hook with the driver fixture, or a Cucumber After hook
- In a try-catch inside every test
- In the page objects after every action
- Nowhere: logs are enough
This question is part of Pro+
Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.