Skip to content

Docker setup for Nightwatch containerized versions of Chrome, Firefox and Edge on Linux.

License

Notifications You must be signed in to change notification settings

nightwatchjs-community/nightwatch-docker

Repository files navigation

nightwatch-docker

nightwatch-docker-workflow

Docker setup with screen recording support for Nightwatch containerized versions of Chrome, Firefox and Edge on Linux.

Docker Demo

🚀 Quick Start

  1. Clone this repo

  2. Start a docker container using Firefox

    docker run -d -p 4444:4444 --shm-size="2g" selenium/standalone-firefox
  3. Make sure Nightwatch.conf.js has start_process to false.

  4. Run npx nightwatch to run nightwatch tests in Firefox browser.

  5. 🎉 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.

⚙️ Usage

There are two ways a user can run tests with Nightwatch using docker

  1. Using Docker images (As shown in quick start)

    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.

    Video Recording

    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
  2. Using Docker compose

    Chrome Chrome

    docker-compose -f docker-compose.chrome.yml up --exit-code-from nightwatch

    Firefox Firefox

    docker-compose -f docker-compose.firefox.yml up --exit-code-from nightwatch

    Edge Edge

    docker-compose -f docker-compose.edge.yml up --exit-code-from nightwatch

    Selenium Hub

    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

Issues with this nightwatch-docker can filed here

About

Docker setup for Nightwatch containerized versions of Chrome, Firefox and Edge on Linux.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published