Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in DevOps and Agile by (19.7k points)

  Due to my circumstances for the current project I need to use 2 docker images together for selenium testing.

One is called Zalenium. I have it up and working via the docker-compose demo. Its basically like the selenium docker repo except that this can record video and show you live progress



  image: "dosel/zalenium"

        container_name: zalenium

        hostname: zalenium

        tty: true


            - /Users/josephastrahan/seluser/videos:/home/seluser/videos

            - /var/run/docker.sock:/var/run/docker.sock

            - /usr/bin/docker:/usr/bin/docker


            - 4444:4444

        command: >

          start --chromeContainers 1

                --firefoxContainers 1

                --maxDockerSeleniumContainers 8

                --screenWidth 800 --screenHeight 600

                --timeZone "Europe/Berlin"

                --videoRecordingEnabled true

                --sauceLabsEnabled false

                --browserStackEnabled false

                --testingBotEnabled false

                --startTunnel false


          - HOST_UID

          - HOST_GID

          - SAUCE_USERNAME

          - SAUCE_ACCESS_KEY



          - TESTINGBOT_KEY


The other image is a NodeJS server pre-installed with Mocha and the nodejs (npm package) of selenium-webdriver so that I can run the commands to trigger browser automation. Details on this here ( and here ( can see Zalenium running from docker compose just fine here. I can see the time updating every second correctly so it's definitely showing a live view.enter image description hereAccording to the documentation for the other docker container I'm using which is here (, I should be able to run tests simply with a docker command like this. 


echo ""

echo "----------------------------"

echo "----------------------------"

echo ""

docker run -it --rm \

    -v $HERE:/workspace \

    qmu1/selenium-webdriver-node:latest /bin/sh -c "

        mocha sample.js --timeout=10000


I changed this command to fit my needs until it seemed liked it worked.

docker run -it --rm --net=distributiontech_default -v $HERE:/workspace qmu1/selenium-webdriver-node:latest /bin/sh -c "mocha tests/seleniumtest.js --timeout=10000"

I got the response:

all modules are ready!

  0 passing (1ms)

The issue using Zalenium is that I didn't see anything happen on the viewer to verify it was even working?

My selenium script looks like below.

//Run using this project (

"use strict";

const webdriver = require('selenium-webdriver'),

    By = webdriver.By,

    until = webdriver.until,

    test = require('selenium-webdriver/testing');

const expect = require('expect.js');

const assert = require('assert');

// var driver = new webdriver.Builder()

//    .withCapabilities(

//    .usingServer('http://localhost:4444/wd/hub')

//    .build();

var driver = new webdriver.Builder()





driver.findElement('q')).sendKeys('simple programmer');



console.log('all modules are ready!');

I tried without the --net command and with... and  no luck. Just so you can see the network details and containers running. You can see that zalenium is added to the distributiontech_default network.

enter image description here

enter image description here

enter image description here

How do I connect the docker container running the selenium code to the docker hub running Zalenium?

I tried changing this to...

var driver = new webdriver.Builder()




but, no luck either. I can put any fake address I want where it says localhost and it doesn't seem to throw any errors or anything either oddly enough.

1 Answer

0 votes
by (62.9k points)

I had a similar issue and I found I could use the --link command so I could link a named Zalenium grid instance with the docker instance which executes my tests:

docker run --privileged --name stg-selenium-client --rm=true --link zalenium:hub <command to execute tests>

Browse Categories