Ejecutar test Selenium en un contenedor Docker Compose

Tiempo de lectura: < 1 minuto

Reading Time: < 1 minute

Today I’m going to show you how we can run Selenium tests in a Docker container.

First, let’s create a Docker Compose container with Selenium (using this image https://github.com/nixel2007/docker-selenium-side-runner)

version: '3'

services:
  chromedriver:
    image: robcherry/docker-chromedriver
    privileged: true
    restart: always
    environment:
      - CHROMEDRIVER_WHITELISTED_IPS=''
    # ports:
    #   - '4444:4444'

  selenium-side-runner:
    image: nixel2007/docker-selenium-side-runner
    # build:
    #   context: .
    volumes:
      - './web/test:/sides'
      - './config/selenium/out:/root/out'

We create two folders, one for the .sides files (exported from Selenium IDE) to execute them:

Folder ./web/test/

And another one for the configuration out that Selenium produces:

Folder ./config/selenium/out

We run the test:

docker compose up

And we can see the test results.

Remember that to run the tests on the environment, we need to set up a Docker container with Nginx or Apache2 and launch the website from it. Another option is to use a remote URL to run the tests.

If we use another Docker Compose container, we need to add both containers to the same Docker network and replace the base URL of the Selenium tests with the name of the container, like:

http://nginx/

Leave a Comment