Containerized Testing using Docker + Selenium
- Sachin Pathare
- May 22, 2017
- 1 min read
Docker + selenium
What is selenium grid : Selenium Grid allows you to run your tests in different machines against different browser in parallel, That is running multiple test at the same time against different machines with different browser and os. it supports distributed execution.
For Grid Architecture check previous blog on selenium grid setup.
You need to have docker install on your machine. please follow steps here to setup docker for your machine.
Standalone Grid : (hub and node on local machines)
If you wants to setup hub and node on same machine you can use standalone grid
1. docker run -d --name selenium -p 5900:5900 -p 4444:4444 selenium/standalone-Firefox-debug
2. open vnc://:secret@192.168.99.100:5900
Pull the selenium hub and node images :
docker pull selenium/hub (pulling all the layers of images)
docker pull selenium/node-chrome
docker pull selenium/node-firefox
Run images :
docker run -d --name hub -p selenium/hub (by default it opens port 4444 otherwise docker decides which port to open)
docker logs hub (check the hub logs)
docker ps (check the running processes)
docker run -d --link hub:hub -P --name chrome selenium/node-chrome
docker run -d --link hub:hub -P --name Firefox selenium/node-Firefox
visit localhost:4444 for selenium grid hub dashboard
Using Docker compose to run all images
Instead of running all images separately you can use docker compose to manage/run all .
1. Create docker-compose.yml file and add following content into it.
selenium-hub image:selenium/hub ports: - 4444:4444
fierfoxnode : image: selenium/node-firefox-debug ports: - 4577 links: - seleniumhub/hub
chromenode : image: selenium/node-chrome-debug ports: - 457 links: 8 - seleniumhub/hub
2. And then run following command to run images.
docker-compose up -d
For more info visit https://github.com/SeleniumHQ/docker-selenium
Comments