How do you set up selenium grid using docker on windows? How do you set up selenium grid using docker on windows? selenium selenium

How do you set up selenium grid using docker on windows?


Unfortunately the selenium docker image might be broken since 4 days ago but you can try my alternative one:

  1. Pull the image and run as many containers as you need

    docker pull elgalu/seleniumdocker run -d --name=grid4 -p 4444:24444 -p 5904:25900 \    -v /dev/shm:/dev/shm -e VNC_PASSWORD=hola elgalu/seleniumdocker run -d --name=grid5 -p 4445:24444 -p 5905:25900 \    -v /dev/shm:/dev/shm -e VNC_PASSWORD=hola elgalu/seleniumdocker run -d --name=grid6 -p 4446:24444 -p 5906:25900 \    -v /dev/shm:/dev/shm -e VNC_PASSWORD=hola elgalu/selenium
  2. Wait until the all the grids started properly before starting the tests (Optional but recommended)

    docker exec grid4 wait_all_done 30sdocker exec grid5 wait_all_done 30sdocker exec grid6 wait_all_done 30s

After this, Selenium should be up and running at http://localhost:4444/wd/hub. Open the url in your browser to confirm it is running.If you are using Mac (OSX) or Microsoft Windows localhost won't work! Find out the correct IP through boot2docker ip or docker-machine ip default.

So set the selenium port accordingly for each of your test:

  • 1st test should connect to http://ipAddress:4444/wd/hub
  • 2nd test to http://ipAddress:4445/wd/hub
  • 3rd test to http://ipAddress:4446/wd/hub

You can run as many as your hardware can take.


Take a look at the Protractor Cookbook w/ Docker. The instructions are listed step-by-step using selenium-grid and docker compose. Docker-selenium issue #208 has been fixed.

So you'll need to pull down the latest images*:

docker pull selenium/hub:latestdocker pull selenium/node-chrome-debug:latest

Start the selenium grid:

docker run -d -p 4444:4444 --name selenium-hub selenium/hub:latest

Then add selenium nodes. I like to use the chrome-debug and firefox-debug versions to VNC to watch the tests.

docker run -d -p <port>:5900 --link selenium-hub:hub selenium/node-chrome-debug:latest

After linking your selenium grid, this should be enough to run your Protractor test using the seleniumAddress: 'http://localhost:4444/wd/hub'.

For debugging, find the VNC port for the container with:

docker port <container-name or container-id> 5900

and access it via VNC Viewer.

Note:

  • At the time of this writing, 'latest' appears to be tied to a ~2.53.1 version of selenium server. As of Protractor 4.0.11 (the latest version of Protractor), this is the supported version that should be used. Note that the instructions on the Selenium-docker GitHub appear to be for tailored for selenium server 3.0.1.


You can use below compose file to setup grid and access via VNC

**# To execute this docker-compose yml file use docker-compose -f up

**# Add the "-d" flag at the end for deattached execution****

version: '2'services:  firefoxnode:    image: selenium/node-firefox-debug    volumes:      - /dev/shm:/dev/shm    depends_on:      - hub    environment:      HUB_HOST: hub    ports:      - "32772:5900"  chromenode:    image: selenium/node-chrome-debug    volumes:      - /dev/shm:/dev/shm    depends_on:      - hub    environment:      HUB_HOST: hub    ports:      - "32773:5900"  hub:    image: selenium/hub    ports:      - "4444:4444"

command I use:

 docker-compose -f .\docker-compose.yml up -d

Source :

https://github.com/SeleniumHQ/docker-selenium