Skip to content

Selenium - Docker

A test autmation Tool

To deploy a selenium Docker stack:
https://github.com/SeleniumHQ/docker-selenium

Qucik test with docker CLI
docker network create grid

## selenium/hub
docker run -d -p 4444:4444 --net grid --name selenium-hub selenium/hub:3.13.0-argon

## nodes firefox et chrome
docker run -d -e HUB_HOST=selenium-hub -v /dev/shm:/dev/shm docker.io/selenium/node-chrome:3.13.0-argon
docker run -d -e HUB_HOST=selenium-hub -v /dev/shm:/dev/shm docker.io/selenium/node-firefox:3.13.0-argon

docker run --name fire_jenk3 -d -e HUB_HOST=server2.example.com -e HUB_PORT=4445 -v /dev/shm:/dev/shm docker.io/selenium/node-firefox:3.13.0-argon

docker network create host_jenk -d host

docker run --name jenkins_firefox  --net host --hostname=server.example.com --ip=10.238.xx.xx -d -e HUB_HOST=server2.example.com -e HUB_PORT=4445 -v /dev/shm:/dev/shm docker.io/selenium/node-firefox:3.13.0-argon

docker run --name jenkins_firefox -d -e HUB_HOST=server2.example.com -e HUB_PORT=4445 -v /dev/shm:/dev/shm docker.io/selenium/node-firefox-debug:3.13.0-argon

docker run --name ${container_name} -d -e HUB_HOST=selenium-hub -e HUB_PORT=4444 -v /dev/shm:/dev/shm ${image_name}

docker network create selenium-grid -d  bridge
docker network connect selenium-grid selenium-hub

docker inspect --format='{{.NetworkSettings.Networks}}' selenium-hub | grep -o "selenium-grid"
With docker-compose.yml
version: '2.1'
services:
  firefox:
    image: docker.io/selenium/node-firefox-debug:3.13.0-argon
    container_name: firefox
    volumes:
      - /dev/shm:/dev/shm
    depends_on:
      - selenium-hub
    environment:
      - HUB_HOST=selenium-hub
      - HUB_PORT=4444

  firefox0:
    image: docker.io/selenium/node-firefox-debug:3.13.0-argon
    container_name: firefox0
    volumes:
      - /dev/shm:/dev/shm
    depends_on:
      - selenium-hub
    environment:
      - HUB_HOST=selenium-hub
      - HUB_PORT=4444

  firefox01:
    image: docker.io/selenium/node-firefox-debug:3.13.0-argon
    container_name: firefox01
    volumes:
      - /dev/shm:/dev/shm
    depends_on:
      - selenium-hub
    environment:
      - HUB_HOST=selenium-hub
      - HUB_PORT=4444

  chrome:
    image: docker.io/selenium/node-chrome-debug:3.13.0-argon
    container_name: chrome
    volumes:
      - /dev/shm:/dev/shm
    depends_on:
      - selenium-hub
    environment:
      - HUB_HOST=selenium-hub
      - HUB_PORT=4444

  selenium-hub:
    image: docker.io/selenium/hub:3.13.0-argon
    container_name: selenium-hub
    ports:
      - "4444:4444"
    volumes:
      - /dev/shm:/dev/shm
    environment:
      - JAVA_OPTS=-Xmx512m

Kotlin

Kotlin is one of best alertnative to selenium
More easy to integarte to CI/CD pipeline

https://kotlinlang.org/