Docker setup with screen recording support for Nightwatch containerized versions of Chrome, Firefox and Edge on Linux.
-
Clone this repo
-
Start a docker container using Firefox
docker run -d -p 4444:4444 --shm-size="2g" selenium/standalone-firefox
-
Make sure
Nightwatch.conf.js
hasstart_process
tofalse
. -
Run
npx nightwatch
to run nightwatch tests in Firefox browser. -
🎉 You have just successfully run your first tests in the Firefox browser.
☝️ When executing docker run for an image that contains a browser please use the flag --shm-size=2g
to use the host's shared memory.
There are two ways a user can run tests with Nightwatch using docker
-
We can use different docker images to start different containers for different browsers.
docker run -d -p 4444:4444 --shm-size="2g" selenium/standalone-<firefox/chrome/edge>
⚠️ Only one docker container can be run at a time, as port will conflict.Tests execution can be recorded by using the
selenium/video
Docker image. One container is needed per each container where a browser is running. This means if you are running 5 Nodes/Standalone containers, you will need 5 video containers, the mapping is 1-1.Currently, the only way to do this mapping is manually (either starting the containers manually, or through docker-compose).
$ docker network create grid $ docker run -d -p 4444:4444 -p 6900:5900 --net grid --name firefox --shm-size="2g" selenium/standalone-firefox $ docker run -d --net grid --name video -v $(pwd)/videos:/videos selenium/video $ npx nightwatch $ docker stop video && docker rm video $ docker stop firefox && docker rm firefox
-
docker-compose -f docker-compose.chrome.yml up --exit-code-from nightwatch
docker-compose -f docker-compose.firefox.yml up --exit-code-from nightwatch
docker-compose -f docker-compose.edge.yml up --exit-code-from nightwatch
docker-compose -f docker-compose.selenium-hub.yml up --exit-code-from nightwatch
Stop and remove container set:
docker-compose -f docker-compose.<service-name>.yml down
service-name would be from either of these
chrome/firefox/edge/selenium-hub
Issues with this nightwatch-docker can filed here