Skip to content

How to Automate Video Streaming Testing Using Selenium

Author: The MuukTest Team

Last updated: March 27, 2024

how to automate video streaming testing using selenium
Table of Contents
Schedule

Since 2004, Selenium has become one of the top open-source frameworks for automating testing. This framework helps validate and test web applications using several languages such as Java, C#, or Python to create the scripts of the tests. 

One of the most common and challenging work cases is automatic video streaming testing. These cases are challenging because video content platforms are usually manually tested. However, some can be automated using Selenium.

Video testing an application is critical, especially for the viewers’ enjoyment. According to a research by Ramesh K. Sitaraman of the University of Massachusetts, viewers begin to abandon the video if it takes longer than 2 seconds to load, meaning video buffering is a big part of the user experience and consequently video testing as well.

An essential aspect of software development, especially web development, is the approach to the audience and the ability to make them revisit your web application. On average, a viewer with a bad experience or a failure on video loading is 2.33% less likely to return to that web app.

There is a section of the Selenium framework called Selenium WebDriver, which allows the user to make a cross-browser test of web applications. This test is very useful for this kind of situation.

Here are some options for users to test a video on a web application using Selenium.

 

Testing Video Streaming Using Selenium WebDriver

Selenium needs to recognize the browser and the video before it starts any test.

Select the browser in which the tests are going to be executed. For this example, we will use Chrome.

WebDriver driver= new ChromeDriver();

Indicate the URL or the local path of the video that is going to be tested, as well as a validation that it loaded correctly after a specific time.

driver.get("<Insert Video URL here>");
 
driver.manage().timeouts().implicitlyWait(<Amount of secconds>, TimeUnit.SECONDS);

Selenium needs a way to click or select certain elements on the web application; that is what the JavaScript Executor is for. With the Executor, the user can manually interact with specific web elements that will be used for testing.

JavascriptExecutor ex = (JavascriptExecutor) driver;

Now we can finally begin to work with the video. There are several aspects of it that can be tested, such as play, pause, set volume, mute, unmute, stop player, among others. Here are some examples of how it can be used with a JavaScript Executor.

 

PLAY

ex.executeScript("jwplayer().play();");
Thread.sleep(2000);

PAUSE

ex.executeScript("jwplayer().pause()");
Thread.sleep(2000);

SET VOLUME

ex.executeScript("jwplayer().setVolume(<Volume Amount>);");
Thread.sleep(2000);

MUTE

ex.executeScript("jwplayer().setMute(true);");
Thread.sleep(2000);

 

Conclusion

Automating code has become more and more important in software development over the last few years, walking aside with customer experience to have the best service and fewer bugs in production. As a result, many new technologies help us automate or create tests much more effortlessly. For example, Selenium WebDriver was one of the strongest and more popular ones at the time. In addition, video testing has become a big part of testing mainly because it is a significant visual help for the user, which is why it is critical to test all the aspects of the video.

Juan Pablo Ramos