How to take screen shot of failed test case only?

Taking Screen shot of all the test cases may create a memory issue, because we will be running the automation suite multiple times. Moreover, we can see the status of test cases (pass / failed / skipped) in the testing report. 
So, what is better is, to take the screen shot of only failed test cases.
Why to take screenshot is required in automation? 
              1. Screenshot helps us to understand the flow of application whether application is behaving correctly or not.
                 2. It helps as while doing cross browser testing.
                3. Another use is, while doing headless testing, you will not see actual GUI screen, but it will run on backend (ex – by using HTMLUnitBrowser ), in that case, we can track failed tests.
Now, there are two ways how we can take screen shot of failed test case only.
             
             1.      By using ITestListener Interface
             2.      By using ITestResult interface in @AfterMethod
In the below links, both the ways of taking screen shot on test failure are covered.

Leave Comment

Your email address will not be published. Required fields are marked *

Looking for learning Framework Development from Scratch? Lookout for Detailed Framework Development videos on YouTube here -

https://www.youtube.com/automationtalks

Get the Framework code at Github Repo: https://github.com/prakashnarkhede?tab=repositories