Tips & Tricks: How to Video Record Selenium Test Cases

March 15, 2019

By Maruthi Ram Pushpala

Many of you are probably aware about capturing screenshots of web pages during test execution. Don’t you think it would be great if you could record videos of your Selenium test cases automatically? Let’s find out how you can do it.

Why do we really need video recordings of Selenium test cases?

Video recordings of Selenium test case execution can play a critical role. Not only would these help in debugging issues more efficiently, we can use recorded videos to show test execution activities to the client or internal stakeholders. Additionally, these recorded videos can be added into the project management tool while creating bugs, which helps in understanding the bug clearly.

Does Selenium WebDriver have a built-in feature to record videos of test cases?

No. Selenium WebDriver does not have any built-in mechanism to record videos of the test cases that are executed.

Read how to Make Continuous Testing the Catalyst in Your Continuous Delivery Process  ||  Our Quality Assurance Team helps our clients deliver tightly integrated insights, technologies, and best practice processes.

Then, how can we achieve it?

You can video record Selenium WebDriver test cases in six steps.

1. Download ATUTestRecorder.jar and ATUReporter_Selenium_testNG.jar

These two jars are available on net and one can simply Google to download them.

2.  Add these jar files into a project folder.

Create a folder called executables inside the project and save the jars in this folder.

Best Practices:

Instead of creating a folder in any desired location of the local computer, it’s a best practice to create a folder inside the project.

Advantages:

  • Avoid hard-coding of the path of the folder when writing the script
  • We can use System.getProperty(“user.dir”) to get the base folder path of the project which works irrespective of the location the project is saved.

3. Add ATUTestRecorder.jar and ATUReporter_Selenium_testNG.jar to project build path

We should follow the steps below to add jars to Build path:

Right click on project >> Select “Properties” >> Select “Java Build Path” >> Select “Libraries” tab >> Click on “Add External Jars” button >> Select ATUTestRecorder.jar and ATUReporter_Selenium_testNG.jar  >> Apply >> OK.

Tips & Tricks How to Video Record Selenium Test Cases

4. Create a folder to store recorded videos

Create a folder with the name ScriptVideos inside the project.

Best Practices:

Instead of creating a folder in any desired location of the local computer, it’s a best practice to create a folder inside the project.

Advantages:

  • Avoid hardcoding of the path of the folder when writing the script.
  • We can use System.getProperty(“user.dir”) to get the base folder path of the project which works irrespective of the location the project is saved.

Finding a bug means that you have a chance to build a better product. Read How to Write a Bug Report: The TA Digital Way  ||  Sign up today for the latest news about your Digital Transformation.

5. Create and run the test

  • Declare ATUTestRecorder in SetUp class

/** The recorder. */

ATUTestRecorder recorder;

  • Use the following code in @BeforeMethod:

Tips & Tricks How to Video Record Selenium Test Cases

Best Practices:

  • Use reflection concept from Java to get the test case name and use the same for the video. This helps in identifying the video by seeing the name.
  • Append the name of the video with the timestamp. This helps to create videos, which run multiple times without overriding the old videos.

Use the following code in @AfterMethod:

Tips & Tricks How to Video Record Selenium Test Cases

Additional things to setup when using Maven project and pom.xml

Tips & Tricks How to Video Record Selenium Test Cases

6. Videos will be created with .mov extension. You can play them to see recorded videos

Check the folder, which is used for the videos. We will find the test case videos with .mov extension. These videos will be automatically named as [testcase name-timestamp].mov

BONUS!

Do you want to delete old videos before starting an execution?

Follow the steps below:

Create a method to delete the old video recordings in Utils class.

Tips & Tricks How to Video Record Selenium Test Cases

Call the method in @BeforeSuite

Tips & Tricks How to Video Record Selenium Test Cases

At TA Digital, we instituted auto-video recording of test cases into the core automation framework and use these videos for defect tracking. This has proved its effectiveness in few of the recent projects where the clients and the development team has clear understanding of the issue by just watching the video. The clients were extremely delighted with the implementation of this and overjoyed to experience an approach where they have very clear understanding of the issue.


GET HELP FROM OUR EXPERTS

Over the past 19 years, we have completed thousands of digital projects globally. We have one of the largest and deepest multi-solutions digital consulting teams in the world. Our proprietary processes and years of Digital Experience expertise have earned us a 97% customer satisfaction rating with our clients ranging from Global Fortune 1000 to Mid-Market Enterprises, leading educational institutions, and Non-Profits.

DesignRush has recognized TA Digital as a top Web Design Agency.

About TA Digital

TA Digital is an innovative digital transformation agency, specializing in delivering digital experience, commerce, and marketing solutions. For nearly two decades, we have been helping traditional businesses transform and create dynamic digital cultures through disruptive strategies and agile deployment of innovative solutions. We are known as a global leader in the digital technology industry for helping marketing leaders achieve their revenue targets, create profitable, omni-channel customer and commerce experiences. TA Digital has high-level strategic partnerships with digital technology companies AdobeMicrosoftSitecoreAcquiaMarketoSAP HybrisElastic Path, IBM Watson Marketing, Coveo and Episerver. The company was named on 2013, 2014, 2015 Inc. 5000 list as one of the fastest-growing technology companies in the United States.