Installing Java on a docker image for Selenium/Nightwatch e2e testing


#1

I’m trying to get my Nightwatch e2e tests to run (CircleCI 2.0). I’m not able to figure out how to get Java installed to run Selenium without having a custom Docker image.

An error occurred while trying to start Selenium. Check if JAVA is installed on your machine.

Additionally, for some strange reason, the build is reported as a Success.

Any advice on how to get this going?


#2

To answer my own question - Custom docker images seem to be the way to do it. Here’s what I use to get nightwatch up and running. Make sure to use the browsers tag on the circleci images - or you’ll run into crazy problems with Chrome and Selenium.

FROM circleci/node:7.10.0-browsers
RUN echo "deb http://http.debian.net/debian jessie-backports main" | sudo tee --append /etc/apt/sources.list
RUN sudo apt-get update
RUN sudo apt-get install -t jessie-backports openjdk-8-jdk

#3

Hello, I have the same problem, but I cant solve it.

Im using v2 with - image: circleci/node:latest
This is my result when trying to run e2e tests:


#4

You need to create your own custom image with Java installed. This image will save you the trouble: https://hub.docker.com/r/karthikiyengar/node-nightwatch/


#5

Hello, thanks. Can you tell more about how to set that custom image? Im newbie with docker and circleci.
Thanks!


#6
  - run: sudo su -c 'echo "deb http://deb.debian.org/debian jessie-backports main" >> /etc/apt/sources.list'
  - run: |
      sudo rm -rf /var/lib/apt/lists/*
      sudo apt-get update
      sudo apt install -t jessie-backports  openjdk-8-jre-headless ca-certificates-java

Doing this on a circleci/node:6.11.1-browsers image and I can run my nightwatch tests just fine with it.


#7

Hi, thanks for your help @ben-watt . I’m still having problems.
This is my config.yml file:

# Javascript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
version: 2
jobs:
  build:
    docker:
      # specify the version you desire here
      - image: circleci/node:6.11.1-browsers

      # Specify service dependencies here if necessary
      # CircleCI maintains a library of pre-built images
      # documented at https://circleci.com/docs/2.0/circleci-images/
      # - image: circleci/mongo:3.4.4

    working_directory: ~/repo

    steps:
      - checkout

      # Download and cache dependencies
      - restore_cache:
          keys:
          - v1-dependencies-{{ checksum "package.json" }}
          # fallback to using the latest cache if no exact match is found
          - v1-dependencies-

      - run: npm install

      - save_cache:
          paths:
            - node_modules
          key: v1-dependencies-{{ checksum "package.json" }}

      - run: sudo su -c 'echo "deb http://deb.debian.org/debian jessie-backports main" >> /etc/apt/sources.list'
      - run: sudo rm -rf /var/lib/apt/lists/*
      - run: sudo apt-get update
      - run: sudo apt install -t jessie-backports  openjdk-8-jre-headless ca-certificates-java

      # run tests!
      - run: npm test

Can you tell me what is wrong? Thanks!!


#8

Hey @baumannzone, I’m working on an article which covers all of these steps in detail. I’ll post the link here in a couple of hours when I’m done.


#9

Nice to hear it. I’ll wait. Thank you.


#10

Hello, @karthikiyengar did you get something? I’m excited!


#11

Hi @baumannzone - You can find it here: https://medium.com/@karthikiyengar/rock-solid-end-to-end-continuous-integration-with-nightwatch-js-545c66c17fdd

Do take some time out to understand how Docker and the CircleCI config.yml works. For now, you can use the custom image that I’ve built here: https://hub.docker.com/r/karthikiyengar/node-nightwatch/

Modify your Docker config to this

    docker:
      - image: karthikiyengar/node-nightwatch:0.0.1

#12

Wow, your docker image is working very well for me! Thanks.:blush:


#13

Glad it was helpful. Cheers.


#14

What @ben-watt posted worked for me. My image was circleci/node:7.10.1


#15

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.