An approach to run selenium UI tests on a dockerized selenium grid with a hub and nodes for different browsers e.g. chrome, firefox etc.
Uses images: hub, node-firefox, node-chrome
- Docker
- Docker Desktop (not mandatory, but recommended to start stop the daemon engine)
- Start the docker engine
Refer: Docker Docs
All configurations to hub and nodes are in docker-compose.yaml file, add/modify nodes based on needs.
To spin up containers, run
docker-compose up
To run in detached mode, run
docker-compose up -d
Go to MainTest to run the sample tests. Add more tests, edit browser configs in DriverSetup. Following dependencies are already included:
- Selenium 4
- TestNG 7
docker-compose down
docker container ps
- list running containers
docker container ps -a
- list running and stopped containers
docker container logs <name or id of container>
- when running in detached mode, to see container logs
docker exec -ti <name or id of container> /bin/bash
- shell into running container to run commands on container's terminal.
-t
- allocates pseudo tty (unix terminology)
-i
- keeps std in open