In a fast-developing IT world, report generation process plays a key role in automation and manual testing. Clear bug reports give QA engineers an understanding of what is going on inside the project, what tests passed, what failed and what needs to be fixed.
Well, what we all know that if we have good test results, we prove that the application is in good condition and there are no crucial bugs for management and development. But let’s say, we have failed test results and we need to investigate what is wrong. Of course, there can be various reasons for failure except for real bugs, for example:
- Changes in the developer’s code.
- Mistakes in the tester’s code.
- Configurations (Jenkins, driver’s updates, browser updates, Java JDK).
After checking functionality and excluding all of the above reasons, we know, we are dealing with a real bug.
When QA reports a bug, they definitely want it to be fixed. And to get the bug fixed faster, QA needs to write an effective report. For example, if a company uses BDD (Behavior-driven development), reports will be Serenity, Allure or Extent both for local and for CI execution. Without any doubt, the Extent Report is the most popular report for any test framework even without BDD. But the thing is, even a good-written report with screenshots, can lead to confusion and it really takes time to understand whether the failure happened in debugging mode or in manual testing. As a result, we have a low efficiency but a high time consumption process.
Sounds not so cool, right? So, let’s use a little bit of “magic” ✨
Magic video reports for Selenium test cases 🤯
Yes, yes, yes! Such a simple feature as video reports creation is an ideal decision for you to save time and effort.
For instance, QA can see that the test is failed only because Selenium can’t click the dynamic element or some actions are not performed. If a company has a license to a cloud platform such as Sauce Labs, it will be easier to understand the root cause of the issue, because cloud testing solutions have video reports, logs, and screenshots of whole execution. But if the company doesn’t have this license, it is much more complicated to understand the origin of an issue.
Now, if you want to use pure Java, the free solution for video reports will consist of many lines of code. To shorten it, you can just add the following:
1. Add video-recorder dependency
TestNG:
- Maven
com.automation-remarks video-recorder-testng LATEST
- Gradle
compile group: 'com.automation-remarks', name: 'video-recorder-testng', version: '1.+'
JUnit:
- Maven
com.automation-remarks video-recorder-junit LATEST
- Gradle
compile group: 'com.automation-remarks', name: 'video-recorder-junit', version: '1.+'
2. Add New Listener / Rule
In TesNG add a new Listener:
@Listeners(UniversalVideoListener.class) //in each test class
In JUnit add a new Rule:
@Rule public VideoRule videoRule = new VideoRule();
JUnit 5:
- Gradle
compile group: 'com.automation-remarks', name: 'video-recorder-junit5', version: '1.+' import com.automation.remarks.junit5.Video;
3. Add @Video annotation to the test case
@Test @Video public void test() throws InterruptedException { driver.get("http://automation-remarks.com"); }
4. Add new empty video folder to the project tree
It helps to generate video reports for local failed test cases as well as to fix many issues in test frameworks, faster than using screenshots. Screenshots don’t display actions of Selenium and all details of failures. Meanwhile, video reports save your time for debugging and set up easy fix in your code. If a test is failed, it generates a video report, if not – it doesn’t save the video report.
- You can create properties file video.properties in classpath:
video.folder=${user home}/video video.enabled=false // default true video.mode=ALL // default ANNOTATED recorder.type=FFMPEG // default MONTE video.save.mode=ALL // default FAILED_ONLY video.frame.rate=1 // default 24 ffmpeg.format=x11grab // default value depends on OS platform ffmpeg.display=:0.0 // default value depends on OS platform ffmpeg.pixelFormat=yuv444p // default yuv420p (for Apple QuickTime player compatibility)
- or with Maven
mvn test -Dvideo.folder=custom_folder // default video -Dvideo.enabled=false // default true -Dvideo.mode=ALL // default ANNOTATED -Drecorder.type=FFMPEG // default MONTE -Dvideo.save.mode=ALL // default FAILED_ONLY -Dvideo.frame.rate=1 // default 24 -Dvideo.screen.size=1024x768 // custom screen size -Dffmpeg.display=:1.0+10,20 // custom display configuration for ffmpeg -Dffmpeg.pixelFormat=yuv444p // default yuv420p
- TestNG RemoteVideoRecorder:
@Listeners(UniversalVideoListener.class) public class IntegrationTest { RemoteWebDriver driver; @BeforeClass public void setUp() throws Exception { URL hubUrl = new URL("http://localhost:4444/wd/hub"); driver = new RemoteWebDriver(hubUrl, DesiredCapabilities.firefox()); String nodeIp = GridInfoExtractor.getNodeIp(hubUrl, driver.getSessionId().toString()); System.setProperty("video.remote", "true"); System.setProperty("remote.video.hub", nodeIp); } @Test @Video public void test() throws InterruptedException { driver.get("http://automation-remarks.com"); } }
Pros and Cons of Video Reports
Advantages
- Easy implementation.
- Helps to understand the root cause of failures.
Disadvantages of this annotation:
- Uses only AVI or FFmpeg format. Not each video player can play these formats.
- The video library can record all your actions on the desktop, not only browser actions.
I highly recommend using this type of video reports for local executions only (when you don’t do additional actions on your desktop). In this case, you can record videos, and if your test cases fail, you have a faster understanding of the issue and how to fix it.
Happy testing to all of you! 😎
You can find the documentation and source code here: https://github.com/SergeyPirogov/video-recorder-java.