Video summary

Session 54: Selenium with Java | Hybrid Framework | Docker Integration with SeleniumGrid

Main summary

Key takeaways

Technology

Technology/Framework Context (Selenium Grid)

The session builds on earlier Selenium Grid concepts: using a Hub + multiple Nodes to execute Selenium tests across multiple browsers.

Today’s focus is adding Docker integration, so Selenium Grid can run without manually provisioning machines or VMs.

Docker Concepts Introduced (Why Docker vs VM)

Virtualization (VMs)

  • Multiple virtual operating systems run on one physical machine.
  • Can be costly and may degrade performance as the number of VMs increases.

Containerization / Docker

  • A replacement approach to avoid running full virtual machines.
  • Uses containers derived from Docker images, typically with better performance.
  • Containers can be started/stopped easily and are well-suited for Selenium Grid nodes.

Key behavioral difference: VMs share host hardware more directly, while containers provide more isolation (less sharing), often improving performance.

Docker Hub, Image, and Container (Key Definitions)

  • Docker Hub: a remote repository where images are stored
    • Maintainers/community push images to Docker Hub.
    • Users pull images from Docker Hub.
  • Docker image: a packaged “software/environment template” downloaded from Docker Hub.
  • Docker container: a runnable instance created from an image.

Docker Setup and Verification Steps (Tutorial-style)

  1. Install Docker Desktop

    • Download the installer for Windows.
    • Install Docker Desktop.
    • Reboot as needed.
  2. Verify Docker is working

    • Run: docker version
      • If errors appear (e.g., Docker daemon not running), restart the Docker Desktop service from Windows Services and possibly reboot.
    • Run: docker compose version
  3. UI vs CLI

    • Docker Desktop UI can show images and containers.
    • Most setup and control is done via the CLI.

Basic Docker Commands (Grouped for Practical Use)

Basic

  • docker version
  • docker info
  • docker --help
  • docker login (optional if using private registries)

Image-related

  • docker images (list local images)
  • docker pull <image> (download from Docker Hub)
  • docker rmi <image_id> (remove an image)

Container-related

  • docker ps (shows running containers only)
  • docker run <image>
    • Creates a container and pulls the image automatically if missing.
  • docker start <container_id|name>
  • docker stop <container_id|name>
  • docker rm <container_id|name>

Notes:

  • docker run can pull + create; using a separate docker pull is optional but can be faster for grid setup.
  • docker ps won’t show containers that exist but are not running.

System helpers

  • docker stats (CPU/RAM usage)
  • docker system df (disk usage)
  • docker system prune -f (clean up stopped containers/resources)

Selenium Grid Containers via Docker (Manual Approach)

The manual approach uses 3 Linux-based Docker images:

  1. Selenium Hub image
  2. Selenium Node for Firefox
  3. Selenium Node for Chrome

Approach

  • Pull the images (example names mentioned):
    • selenium/hub
    • selenium/node-chrome (Chrome node)
    • selenium/node-firefox (Firefox node)
  • Create a Docker network (e.g., grid) so hub and nodes can communicate:
    • docker network create <name>
  • Create containers attached to that same network:
    • One container for Hub
    • One container per node/browser
  • Hub uses the standard Grid URL: http://localhost:4444

Grid execution verification

  • After containers are running, tests are launched using a Selenium Grid XML setup.
  • Headless execution is implied (tests run without visible UI).
  • Session mapping:
    • Each test suite run creates Grid sessions mapped to the selected node (Chrome vs Firefox).
    • Reports are generated per execution round.

Running Tests Using Grid XML (Key Integration Point)

  • The existing framework base class is reused.
  • Only a Grid-specific XML is changed:
    • Select OS = Linux
    • Select browser (Chrome or Firefox)
    • Keep the Hub URL the same
  • Result:
    • Tests execute on the correct node(s) based on XML selection.
    • Sessions appear under Grid’s Sessions UI, and reports reflect pass/fail status.

Cleanup / Lifecycle Control

Containers can be stopped/removed via:

  • Docker Desktop UI (stop button)
  • Docker commands (stop/start/rm)

After stopping, running docker ps shows nothing because containers are no longer running.

Automation Improvement: Docker Compose (Automated Approach)

Why Compose

The manual method is repetitive:

  • You must manually pull images, create containers, and connect them to the network.
  • Adding more nodes (Edge/Opera/etc.) increases manual command workload.

Docker Compose solution

  • Use a Docker Compose YAML file that defines:
    • network name
    • hub service
    • node services (and can scale multiple node instances)
  • Start everything with:
    • docker compose up (using the YAML file location)

Benefit: one command brings up the entire Selenium Grid environment.

Scaling

  • Mentions scaling instances (e.g., more Chrome/Firefox nodes) with Compose to increase parallel sessions.
  • The subtitles had minor inconsistency in the exact command syntax, but the intent was clear.

Main Speakers/Sources

  • Single main instructor/speaker (no named secondary sources mentioned).

Original video