Selenium on Circle CI 2



Did anyone manage to get a firefox/chrome container working with Circle CI 2?

I tried multiple images from Docker Hub but they all fail to connect… and without any debugging capabilities I am kind of lost


I used WDIO without any issues:


Thanks Alex, but that’s on Circle 1. I’m having issued with Circle 2 :slight_smile:


I have gotten Selenium running on 2.0.

This is my Dockerfile:

FROM buildpack-deps:jessie

RUN groupadd --gid 1000 node \
  && useradd --uid 1000 --gid node --shell /bin/bash --create-home node

# gpg keys listed at
RUN set -ex \
  && for key in \
    9554F04D7259F04124DE6B476D5A82AC7E37093B \
    94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
    0034A06D9D9B0064CE8ADF6BF1747F4AD2306D93 \
    FD3A5288F042B6850C66B31F09FE44734EB7990E \
    71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \
    DD8F2338BAE7501E3DD5AC78C273792F7D83545D \
    B9AE9905FFD7803F25714661B63B535A4C206CA9 \
    C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \
  ; do \
    gpg --keyserver --recv-keys "$key"; \


RUN curl -SLO "$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.xz" \
  && curl -SLO "$NODE_VERSION/SHASUMS256.txt.asc" \
  && gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
  && grep " node-v$NODE_VERSION-linux-x64.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
  && tar -xJf "node-v$NODE_VERSION-linux-x64.tar.xz" -C /usr/local --strip-components=1 \
  && rm "node-v$NODE_VERSION-linux-x64.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \
  && ln -s /usr/local/bin/node /usr/local/bin/nodejs \
  && apt update \
  && apt install -y git ocaml libelf-dev firefox-esr chromedriver xvfb openjdk-7-jdk

RUN npm install -g yarn@0.18.0
ENV PATH "$PATH:/root/.yarn/bin/"

CMD [ "node" ]

This is the relevant bit of circle.yml:

          - type: shell
            name: Start Xvfb
            command: |
              wget -O selenium-server.jar
              Xvfb :7055
            background: true


In CircleCI 2.0 you can use selenium/standalone images.

Simply add the following to config.yml:

  - image: selenium/standalone-chrome:3.1.0

Current versions for Firefox and Chrome:

Your tests should now run just as they do locally if you’re set up for webdriver / selenium etc.


Worked! Thanks!!


Hi, we’re trying to get Selenium working with Circle 2.0 with python tests but the code doesn’t find the chromedriver or geckodriver executable, complains that it needs to be in PATH.

This is our circle.yml:

version: 2
    working_directory: ~/working
      - image: truckfly/python-yarn:latest
      - image: postgres:9.4.11
          POSTGRES_USER: ubuntu
          POSTGRES_DB: circle_test
      - image: selenium/standalone-chrome:latest
      - checkout
      - restore_cache:
          key: dashdoc-venv-{{ checksum "requirements.txt" }}
      - run:
          name: Install pip packages
          command: virtualenv venv; source venv/bin/activate; pip install -r requirements.txt
      - save_cache:
          key: dashdoc-venv-{{ checksum "requirements.txt" }}
            - "./venv"
      - restore_cache:
          key: dashdoc-yarn-{{ checksum "yarn.lock" }}
      - run:
          name: Install npm packages
          command: yarn
      - save_cache:
          key: dashdoc-yarn-{{ checksum "yarn.lock" }}
            - "~/.yarn-cache"
      - run:
          name: Javascript tests
          command: yarn test
      - run:
          name: Python tests
          command: coverage run test
      - run:
          name: Code coverage
          command: codecov -t key

Any idea?


I’d use one of our Python based browser images;

You can extend it and install Yarn.


Hi @rohara, thanks for the response. Using python2.7-browser as the base image yields the same results during tests. Do we still need to have the - image: selenium/standalone-chrome:latest line in the circle.yml? It’s not very clear in the docs how the different containers specified in circle.yml interact. When I SSH into the build I don’t have access to the docker command which makes it even harder to debug things…


I don’t see how that would help you debug your Python app.

No. It’s installed on the container you’re using so there’s no need.

Have you gotten browser testing working elsewhere? With what versions of software?


@rohara thanks for your help, we got it working with the python-2.7-browsers image. Sorry for the latest message, it was an unrelated problem.

The bit about being able to see which containers are up and running on the SSH build was maybe more due to confusion about whether we are running inside the primary container or on the host VM when ssh-ing into the build, and how to locate/access the other docker containers that are running. It’s also that I don’t have much experience with docker…


You SSH into the primary container (the first one listed in the docker bit of the config). The other container logs are accessible from within a given build page.

I hope this helps!



I am trying to run tests on 5 browsers (Chrome, Opera, Firefox, Safari, IE) on a docker image, solely so I can run integration tests locally before it runs on circle ci when I push changes over. We are using webdriverio’s testrunner to run our cucumber tests. When I run with Chrome and Safari (in developer mode) locally everything works fine, however, I start getting problems with all browsers when I try to run in docker. There is no debugging with the errors so I’m pretty lost. If any of you are familiar with the use-case I am writing about I would really appreciate some help.


I recommend using one of the browser variants of our CircleCI Images for simplicity.


Hi @rohara

Thank you for that excellent suggestion! I am using this circleci/node image with tag latest-browsers and getting the folowing error before booting into the container via bash:

ERROR: euid != 0,directory /tmp/.X11-unix will not be created.

Seems to be about graphics driver, probably from chrome, any help in this area?


Just ignore it, it’s irrelevant.


One more thing @rohara, how can I access the Dockerfiles for your pre-built images?



Hi @tom,

What url do you point the browser to then? Let’s say I have a webserver running in my main image on port 80. Do i point the browser to localhost?

I can connect to the selenium driver but the browser always crashes on Connection refused when trying to display a page.


Is there a reason your tutorial doesn’t use these