Debugging Docker Container with RealVNC Viewer

In our last article, we talked about basics of running automation Test on Docker. Now, this article is more about debugging the Test running on the containers. It’s helpful when you want to see what is happening inside the docker container.
In the event you wish to visually see what the browser is doing you will want to run the debug variant of the node or standalone images. A VNC server will run on particular port inside the container with Selenium WebDriver.

Download RealVNC viewer:

You can download the real-vnc.
and Install as per your operating system.

Pull Selenium Chrome-Debug Image:

Step:1 For the Debugging we should require the Docker Selenium WebDriver Image with VNC server.So First Step is to download the Docker Image with Debugging.

docker pull selenium/standalone-chrome-debug

Docker pull will start downloading the image if it’s not already downloaded.

Step 2: After downloading the proper debugging image, we need to start the docker container for the image:

docker run -d -P selenium/standalone-chrome-debug

Step 3: After running the Docker container we should verify the Container Process and Port Details.

docker ps

You can acquire the port by looking at the container details Like from the Image above we can see the
VNC server is listening on the Port No: 32771

Start VNC and Create VNC:

Step 1: Open real VNC viewer downloaded in the previous Steps.

Step 2: From File Menu select: Create New Connection

Step 3: Enter Value of VNC Server as localhost:
Step 4: Now You will be able to see the VNC server created and Open the Connection.

Step 5: When you are prompted for the password it is secret

Now Our Selenium WebDriver container is Running and VNC server is Running. We can now run our Test and we will be able to see the Browser driving the Test cases on VNC server.

Create WebDriver Test and Run Test:

Create a simple Java test which is opening the Google.com in the container and Post Number should be edited from the container details.

Running Our Test on the correct Port number will Open the Google in our Container and We can see the Browser running in our VNC Server.

Benefits of using VNC and Debug:

Using the VNC server are helpful in debugging and seeing what is happening in the Test while running inside the container. There are many Selenium WebDriver Images providing the test to be recorded as video.