Public | Automated Build

Last pushed: 8 days ago
Short Description
Protractor tests execution environment
Full Description

Dockerfile for Protractor test execution

This image contains a fully configured environment for running Protractor tests
under Chromium and Firefox browsers.

Installed software

  • Xvfb The headless X server, for running browsers inside Docker
  • node.js The runtime platform for running JavaScript on the server side, including Protractor tests
  • npm Node.js package manager used to install Protractor and any specific node.js modules the tests may need
  • Selenium webdriver Browser instrumentation agent used by Protractor to execute the tests
  • Java 8 SE Needed by Selenium
  • Chromium The OSS core part of Google Chrome browser
  • Firefox Firefox browser
  • Protractor An end-to-end test framework for web applications
  • Supervisor Process controll system used to manage Xvfb and Selenium background processes needed by Protractor

Running

In order to run tests from a CI system, execute the following:

docker run --rm -v <test project location>:/project caltha/protractor

The container will terminate automatically after the tests are completed. The output of supervisord visible on the console is not interesting in most circumstances. You should check target/supervsor.out file to see the output of Protractor. Dispalying the file in an Unix terminal using cat is recommended over opening it using an editor because the file contains ANSI escape sequences.

If you want to run the tests interactively you can launch the container and enter into it:

CONTAINER=$(docker run -d -v <test project location>:/project --env MANUAL=yes caltha/protractor)
docker exec -ti $CONTAINER sudo -i -u node bash

When inside the container you can run the tests at the console by simply invoking protractor. When things don't work as expected, you should check Selenium WebDrover output in /var/log/supervisor/webdriver-err.log. When you are done, you terminate the Protractor container with docker kill $CONTAINER

CI systems integration

An example project included in the source repository show how jasmine-reporters module can be used to generate JUnit-style test reports that can be used by Jenkins and other tools to display test results or fail the build if test failures are detected.

Docker Pull Command
Owner
caltha
Source Repository

Comments (5)
user1989
3 months ago

Hello,
I get this error when i try to run the docker - rpc error: code = 2 desc = containerd: container not started. What does this error mean?

jaschweder
10 months ago

Hi, maybe anyone can help me, I'm facing this error:

Failures:
1) angularjs homepage todo list should add a todo
Message:
Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
Stack:
Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
at Timer.listOnTimeout (timers.js:92:15)
Message:
Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
Stack:
Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
at Timer.listOnTimeout (timers.js:92:15)

1 spec, 1 failure
Finished in 33.048 seconds

My protractor.conf.js

exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
framework: 'jasmine',
specs: ['todo-spec.js'],
capabilities: {
'browserName': 'chrome',
'chromeOptions': {
'args': ['no-sandbox']
}
}
}

johanvogelzang
2 years ago

Hi Caltha,

It seems like the container does not automatically terminate after Protractor has completed.

==> supervisord.log <==
2015-10-12 12:17:23,814 CRIT Supervisor running as root (no user in config file)
2015-10-12 12:17:23,814 WARN Included extra file "/etc/supervisor/conf.d/protractor.conf" during parsing
2015-10-12 12:17:23,814 WARN Included extra file "/etc/supervisor/conf.d/webdriver.conf" during parsing
2015-10-12 12:17:23,814 WARN Included extra file "/etc/supervisor/conf.d/xvfb.conf" during parsing
2015-10-12 12:17:23,822 INFO RPC interface 'supervisor' initialized
2015-10-12 12:17:23,823 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2015-10-12 12:17:23,823 INFO supervisord started with pid 1
2015-10-12 12:17:24,828 INFO spawned: 'webdriver' with pid 8
2015-10-12 12:17:24,836 INFO spawned: 'xvfb' with pid 9
2015-10-12 12:17:24,846 INFO spawned: 'protractor' with pid 10
2015-10-12 12:17:24,877 INFO exited: protractor (exit status 1; not expected)
2015-10-12 12:17:26,351 INFO success: webdriver entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2015-10-12 12:17:26,352 INFO success: xvfb entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2015-10-12 12:17:26,357 INFO spawned: 'protractor' with pid 39
2015-10-12 12:17:27,976 INFO success: protractor entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2015-10-12 12:17:43,558 CRIT reaped unknown pid 85)
2015-10-12 12:17:43,560 CRIT reaped unknown pid 65)
2015-10-12 12:17:44,205 INFO exited: protractor (exit status 0; expected)

==> protractor-out.log <==
Selenium server is not available
ERROR: unix:///var/run/supervisor.sock refused connection (already shut down?)

Could you please give us some help?

Regards,
Johan.

surfjedi
2 years ago

this looks great but I can't start the server?

Here are the error logs:

/python2.7/dist-packages/supervisor/options.py:296: UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations (including its current working directory); you probably want to specify a "-c" argument specifying an absolute path to a configuration file for improved security.
'Supervisord is running as root and it is searching '
2015-09-28 04:57:27,240 CRIT Supervisor running as root (no user in config file)
2015-09-28 04:57:27,240 WARN Included extra file "/etc/supervisor/conf.d/xvfb.conf" during parsing
2015-09-28 04:57:27,241 WARN Included extra file "/etc/supervisor/conf.d/webdriver.conf" during parsing
2015-09-28 04:57:27,241 WARN Included extra file "/etc/supervisor/conf.d/protractor.conf" during parsing
2015-09-28 04:57:27,248 INFO RPC interface 'supervisor' initialized
2015-09-28 04:57:27,248 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2015-09-28 04:57:27,248 INFO supervisord started with pid 1
2015-09-28 04:57:28,253 INFO spawned: 'webdriver' with pid 7
2015-09-28 04:57:28,256 INFO spawned: 'xvfb' with pid 8
2015-09-28 04:57:28,258 INFO spawned: 'protractor' with pid 9
2015-09-28 04:57:28,286 INFO exited: protractor (exit status 1; not expected)
2015-09-28 04:57:29,657 INFO success: webdriver entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2015-09-28 04:57:29,658 INFO success: xvfb entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2015-09-28 04:57:29,660 INFO spawned: 'protractor' with pid 47
2015-09-28 04:57:29,777 INFO waiting for webdriver, xvfb, protractor to die
2015-09-28 04:57:29,777 INFO stopped: protractor (terminated by SIGTERM)
2015-09-28 04:57:29,783 INFO stopped: xvfb (exit status 0)
2015-09-28 04:57:29,784 CRIT reaped unknown pid 52)
2015-09-28 04:57:29,785 INFO stopped: webdriver (exit status 143)

janvo
2 years ago

We have a problem with the width of the browser. It is always 1050 no matter waht settings for Xvfb we provide. See question @stackoverflow
how-to-start-a-wide-browser-inside-a-docker-container-for-protractor-testing
Maybe someone here knows the answer?