I'm super new to both Docker and CodeceptJs coming from a Selenium/Java background and am trying to run our CodeceptJs tests from within a docker container. However, we get this error and not sure how to bypass it please.
I tried to initiate the Selenium driver under another window (it's not under my project folder) as per here using java -jar selenium.jar
but the same issue still persists.
If we were using raw Selenium outside CodeceptJs most answers here talk about setting some options to the ChromeDriver instance, but ChromeDriver configs seem to be abstracted away from me within the CodeceptJs framework so I think I'm a bit stuck now please.
This is our complete Dockerfile and bash script
FROM docker.br.hmheng.io/base-ubuntu:java_1.8.0_74-b02
ENV DEBIAN_FRONTEND noninteractive
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - \
&& sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list' \
&& apt-get clean \
&& apt-get update \
&& apt-get install curl -y \
dpkg
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
RUN apt-get install -y \
libgconf-2-4 \
libexif12 \
supervisor \
netcat-traditional \
google-chrome-stable \
git \
chromium-chromedriver \
nodejs \
xorg \
xvfb \
dbus-x11 \
xfonts-100dpi \
xfonts-75dpi \
xfonts-scalable \
xfonts-cyrillic \
dos2unix \
--no-install-recommends
ENV JAVA_HOME /usr/lib/jvm/java-8-oracle
ENV HOST selenium
RUN export JAVA_HOME=/usr/lib/jvm/java-8-oracle \
&& export HOST=selenium
COPY ./update-catalog-admin/tests/e2e/scripts/start.sh start.sh
RUN chmod 777 start.sh \
&& dos2unix start.sh
And
#!/bin/bash
echo "[INFO] Starting X server"
Xvfb :0 -screen 0 1600x1200x24 2>&1 >/dev/null &
export DISPLAY=:0
cd /project
node -v
npm -v
ls -lsa
npm install
npm test
Running through this command:
docker run -u 500:500 -v /etc/passwd:/etc/passwd:ro -v $(pwd)/update-catalog-admin/tests/e2e:/project:rw -v /dev/shm:/dev/shm --shm-size=4g update-catalog-e2e-container sh start.sh
And with this codecept.conf.js
exports.config = {
output: './output',
helpers: {
WebDriver: {
url: 'https://api.int.br.internal',
browser: 'chrome'
},
AssertWrapper: {
require: 'codeceptjs-assert',
},
},
include: {
I: './steps_file.js',
createNotificationPage: "./pages/create_notifications.page.js",
},
mocha: {},
bootstrap: null,
teardown: null,
hooks: [],
gherkin: {
features: './features/*.feature',
steps: ['./step_definitions/steps.js']
},
plugins: {
wdio: {
enabled: true,
services: ['selenium-standalone']
// additional config for service can be passed here
},
screenshotOnFail: {
enabled: true
},
pauseOnFail: {},
retryFailedStep: {
enabled: true
},
},
tests: './*_test.js',
name: 'codeceptjs_webdriver'
}
Thank you very much.
We found where to set the ChromeOptions
within the codecept.cong.js
file and it's working now.
output: './output',
helpers: {
WebDriver: {
url: 'https://api.int.br.internal',
browser: 'chrome',
smartWait: 10000,
waitForTimeout: 10000,
timeouts: {
script: 10000,
pageLoad: 60000,
implicit: 10000,
},
desiredCapabilities: {
chromeOptions: {
args: [
'--no-sandbox',
'--disable-gpu',
'--disable-dev-shm-usage',
'--ignore-certificate-errors',
],
excludeSwitches: ['enable-automation'],
},
},
restart: false,
windowSize: '1600x1200',
},
AssertWrapper: {
require: 'codeceptjs-assert',
},
},