Setup Docker for Selenium automation using YAML file

This is in continuation of my previous post on docker where i have show how to configure docker environment for selenium automation. Here we will move a step further and show you Setup Docker for Selenium automation using YAML file.

Automated end-to-end testing requires an environment in which to run tests. Compose yaml files provides a convenient way to create and destroy isolated testing environments for your test suite.
By defining the full environment in a Compose file, you can create and destroy these environments in just a few commands

Prerequisite

Install docker desktop and pull docker build for selenium as show in my previous posts.

Sample Yaml file

version: "3"
services:
selenium-hub:
image: selenium/hub:4.1.4-20220427
container_name: selenium-hub-example
ports:
- "4444:4444"
chrome:
image: selenium/node-chrome:4.1.4-20220427
container_name: chrome1-example
ports:
- "5901:5910"
volumes:
-/dev/shm:/dev/shm
depends_on:
-selenium-hub
environment:
-HUB_HOST:selenium-hub
-HUB_PORT:4444
links:
- selenium-hub

Run the following command

docker-compose up -d

You can also refer yaml file from github.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.