SDET Unicorns

Debug Selenium Tests in Docker using VNC Viewer

Table of Content

In the previous post, we learned how to integrate Selenium tests with Docker. In this tutorial, we will take a look at how to integrate VNC Viewer with Docker and debug Selenium tests in Docker using VNC Viewer. We will also learn why it’s important to run tests through VNC Viewer as well.

Why run Selenium tests in Docker using VNC viewer?

Originally, when I was preparing this post, I was going to name the title “View Selenium Tests in Docker using VNC Viewer”. Because I thought the goal is to be able to view the tests running in VNC.

However, the main reason we want to view tests in VNC viewer is to be able to debug any test issues that are happening inside the Docker. Typically, when tests are being triggered inside Docker container, you are not able to see anything that’s happening inside. But, with the help of the VNC viewer, you get a visual representation of exactly what’s going on inside Docker which makes it easier to debug your test issues. 


Prerequisite

  • Install a VNC client: the one I am using in this tutorial is the RealVNC
  • Use Selenium Debug images: to be able to see what’s going inside the Docker container, you will need to use an image that has a VNC server installed. Any image that ends with -debug will have a VNC server installed
  • Map external VNC port to the Docker VNC port (5900): when you will run the docker image you will need to map the local VNC port to Docker VNC port (5900)

Run Selenium Standalone Debug Docker image 

Let’s run the selenium/standalone-chrome-debug image and map the VNC port with it — 

docker run -d -p 4444:4444 -p 5900:5900 --shm-size=2g selenium/standalone-chrome-debug:3.141.59-20210607
  • -p 4444:4444 is the port for your local machine mapping to Docker Selenium server port 4444
  • -p 5900:5900 is the port for your local VNC server mapping to Docker VNC server

Open Real VNC client

Now that we have a docker image running mapped to port 5900, we can open that port in VNC viewer. To do that, open up the RealVNC client and type in the URL — 127.0.0.1:5900, and hit Enter. 

When prompted for a password, type secret and continue. 

1*mjLVSZzFvwrYz0vLXqqHMg
VNC server pointed to port 5900

Run tests in Docker

Now it’s time to run tests in Docker, make sure your tests are pointed to port 4444 as that is what we have set up for our docker container (you can check out my previous post to learn more about that). 

Once you will run your tests, you will notice the tests can be viewable in the VNC viewer. ??

1* 8PNrM4HRB7y6vVJLA7X2w
Viewing Docker tests in VNC viewer

Check out the video below to learn more about how to execute Selenium tests in Docker and view it in VNC Viewer–

In the next tutorial, I will show you how to set up Selenium Grid and run it in Docker. 

Thanks for reading.

My Resources

Thrive Suite: The all-in-one WordPress theme I used to create my blog.
Jasper AI: My favorite AI writing tool.
Surfer SEO:  A tool to help you rank your content on the first page of Google.

Write Content Faster

5/5

Write blog posts that rank for affiliate terms!

Join our mailing list

Unlock the Secrets to Becoming a SDET Pro in the Industry!

Stay ahead of the curve! Join our mailing list for exclusive insights, tips, and the latest industry updates delivered straight to your inbox

Table of Content

Related Post

7 Principles of Software Testing

7 Principles of Software Testing with Examples

Software testing plays a crucial role in the software development life cycle as it helps ensure the quality, reliability, and performance of the final product. Software testing is not just about finding defects; it also provides valuable insights into the overall quality of the software. By conducting effective software testing, it shows how well the application behaves in different scenarios and whether it meets user expectations.

Read More »
Differences Between CI/CD and DevOps

Key Differences Between CI/CD and DevOps

Software development is far from a simple journey that involves merely executing code and launching applications. It often presents challenges, as it’s rare to get everything right from the start. Each time you implement new or frequent code changes, you inadvertently introduce potential issues that can be time-consuming to resolve. This complexity necessitates a structured approach to ensure smooth production.

Read More »