atlassian / docker-chromium-xvfb Goto Github PK
View Code? Open in Web Editor NEWDocker image for running browser tests against headless Chromium
License: MIT License
Docker image for running browser tests against headless Chromium
License: MIT License
The image in the DockerHub is not up-to-date due to the failed build. Please check here for the build logs:
https://hub.docker.com/r/markadams/chromium-xvfb-js/builds/bhtxre5hksy6yfkkyrdqj2d/
The cause seems to be a unsuccessful installation of the abbrev
npm package.
When using your "onbuild" js container I always get:
no such file or directory, open '/app/package.json'
I think this has to do with the fact that this container extends the base container which sets the WORKDIR as /app but npm install needs to be run from /app/src?
Hi! How can we switch the tool:pytest to be in html, just need to send it out by mail formatted and in xml I miss all the breaklines T_T
The basic image can not be installed Twisted @mark-adams
Image size would be dramatically less Alpine.
Example Dockerfile:
FROM alpine:3.8
RUN apk add --no-cache chromium
RUN addgroup -S chromium && adduser -S chromium -G chromium
USER chromium
EXPOSE 9222
ENTRYPOINT ["chromium-browser", "--no-sandbox", "--disable-gpu", "--headless"]
CMD ["--remote-debugging-address=0.0.0.0", "--remote-debugging-port=9222"]
I'm new to selenium, docker, xvfb and sys admin stuff in general. I find this project more clear to use than the official selenium repo. I've actually not been able to wrap my head around how to actually layer their project into my stack. This project, however, is very intuitive to me and I was able to immediately look at your sample and figure it out.
So those are my reasons for attempting to build my own selenium-ready container...
What reasons do you have for not using the 'official' image?
What are your future goals / plans for this project, if any?
Also, if possible, do you think you could explain the non-obvious differences between this project and that? (Dont need you to tell me you dont have FireFox, for example :p)
Hello,What is the purpose of xvfb?
On a clean checkout of your repo, I get:
~/code/docker-chromium-xvfb/samples/js $ docker build -t xvfb-sample . && docker run xvfb-sample
Sending build context to Docker daemon 6.144 kB
Step 1/1 : FROM markadams/chromium-xvfb-js:7-onbuild
# Executing 3 build triggers...
Step 1/1 : COPY package.json /usr/src/app/package.json
---> Using cache
Step 1/1 : RUN npm install
---> Using cache
Step 1/1 : COPY . /usr/src/app
---> Using cache
---> 2f33936ff9d4
Successfully built 2f33936ff9d4
> [email protected] test /usr/src/app
> ./node_modules/karma/bin/karma start
/usr/src/app/node_modules/socket.io/lib/store.js:35
Store.prototype.__proto__ = EventEmitter.prototype;
^
TypeError: Cannot read property 'prototype' of undefined
at Object.<anonymous> (/usr/src/app/node_modules/socket.io/lib/store.js:35:41)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/src/app/node_modules/socket.io/lib/manager.js:16:13)
at Module._compile (module.js:571:32)
npm ERR! Test failed. See above for more details.
~/code/docker-chromium-xvfb/samples/js $ docker --version
Docker version 17.03.1-ce, build c6d412e
~/code/docker-chromium-xvfb/samples/js $ uname -a
Darwin hickory.local 16.5.0 Darwin Kernel Version 16.5.0: Fri Mar 3 16:52:33 PST 2017; root:xnu-3789.51.2~3/RELEASE_X86_64 x86_64
Are there any plans to prepare js/Dockerfile-10.x ?
Can you tag images with a version in addition to applying the latest
tag? Makes it easier to consume these fantastic images :-)
See also: https://medium.com/@mccode/the-misunderstood-docker-tag-latest-af3babfd6375#.2rq93tci3 for how convoluted docker tags are...
Here my error with npm v3.10.6
npm ERR! not found: git
npm ERR!
npm ERR! Failed using git.
npm ERR! This is most likely not a problem with npm itself.
npm ERR! Please check if you have git installed and in your PATH.
Hi
Running a python test script, I get:
Traceback (most recent call last):
File "mcanvas-login-test.py", line 19, in testLogin
element.send_keys(os.getenv('MCANVAS_TEST_EMAIL'))
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webelement.py", line 320, in send_keys
self._execute(Command.SEND_KEYS_TO_ELEMENT, {'value': keys_to_typing(value)})
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webelement.py", line 461, in _execute
return self._parent.execute(command, params)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response
raise exception_class(message, screen, stacktrace)
WebDriverException: Message: unknown error: an X display is required for keycode conversions, consider using Xvfb
(Session info: chrome=52.0.2743.116)
(Driver info: chromedriver=2.19.346067 (6abd8652f8bc7a1d825962003ac88ec6a37a82f1),platform=Linux 4.4.14-moby x86_64)
Any ideas? I tried just going to a page and checking the page title and everything worked, so I thin it's all installed OK.
Thanks, Roger
I'd quite like to reuse some of this in one of my projects (specifically: your xvfb-chromium script), but you don't include any licensing details in the repo, so I technically can't.
Assuming that you intended this to be open-source, any chance you could drop in an appropriate license?
Hii Adams,
test_google_with_send_keys (testing.ExampleTests) ... ERROR
test_google_without_send_keys (testing.ExampleTests) ... ok
======================================================================
ERROR: test_google_with_send_keys (testing.ExampleTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/tests/testing.py", line 19, in test_google_with_send_keys
input_box.send_keys('apple', Keys.RETURN)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webelement.py", line 349, in send_keys
'value': keys_to_typing(value)})
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webelement.py", line 493, in _execute
return self._parent.execute(command, params)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 256, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
WebDriverException: Message: unknown error: an X display is required for keycode conversions, consider using Xvfb
(Session info: chrome=57.0.2987.98)
(Driver info: chromedriver=2.28.455506 (18f6627e265f442aeec9b6661a49fe819aeeea1f),platform=Linux 3.13.0-38-generic x86_64)
----------------------------------------------------------------------
Ran 2 tests in 15.282s
FAILED (errors=1)
Hi,
First let me apologize if this doesn't make sense, I have literally never used any of the technologies involved here (except for docker), I just agreed to help one of the dev teams rebase their custom container to something more maintained.
They use Capybara with Cucumber, and this then starts up a Selenium driver (against Chrome) to actually run the tests. When the tests kick in I get:
@test-suite
Feature: Smoke Test
@smoke-test @login-IC @showDynamicProductStrategies
Scenario: Configure one medical product and two groups # features/regression/build-smoke-test.feature:5
unknown error: an X display is required for keycode conversions, consider using Xvfb
(Session info: chrome=57.0.2987.98)
(Driver info: chromedriver=2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux 4.4.0-51-generic x86_64) (Selenium::WebDriver::Error::UnknownError)
I changed the configuration for capybara to:
Capybara.register_driver :selenium do |app| # sets the context of a web app
Capybara::Selenium::Driver.new(app,
browser: :chrome,
:desired_capabilities => Selenium::WebDriver::Remote::Capabilities.chrome(
'chromeOptions' => {
'binary' => '/usr/bin/google-chrome'
}
)
) # sets chrome as the browser
Trying to force it through the wrapper script but it still seems to fail. I know this isn't exactly a problem with your container, I am just literally begging for help here as I don't know what else to even do to troubleshoot this. Anything you could suggest would definitely be appreciated!
Hello,
I tried the Image to build a custum container that is expected to run e2e Test using Protractor, not Karma.
Using your Instructions I added npm global Installations for webdriver and protractor. When the container gets up, it yields:
root@gitlab2-VirtualBox:/home/tp-docker/git/docker-chromium# docker run --name e2e e2e-chr Xlib: extension "RANDR" missing on display ":99". [7:16:0524/071954.451043:ERROR:bus.cc(427)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory Xlib: extension "RANDR" missing on display ":99". libudev: udev_has_devtmpfs: name_to_handle_at on /dev: Operation not permitted [51:51:0524/071954.830454:ERROR:child_thread_impl.cc(762)] Request for unknown Channel-associated interface: ui::mojom::GpuMain [7:32:0524/071954.831926:ERROR:browser_gpu_channel_host_factory.cc(125)] Failed to create channel. [7:32:0524/071954.832024:ERROR:browser_gpu_channel_host_factory.cc(125)] Failed to create channel. [7:32:0524/071954.833349:ERROR:browser_gpu_channel_host_factory.cc(125)] Failed to create channel. [7:32:0524/071954.834286:ERROR:browser_gpu_channel_host_factory.cc(125)] Failed to create channel. [7:32:0524/071954.834625:ERROR:browser_gpu_channel_host_factory.cc(125)] Failed to create channel. libudev: udev_has_devtmpfs: name_to_handle_at on /dev: Operation not permitted
Afterwards, the container hangs just, doing nothing more.
Is it even possible to use the Image with Protractor?
It says now: bash: git: command not found
. How can we fix it?
Hey!
Interesting project you've got here! Who knew trying to run Selenium tests in a Docker container would be such a PITA?
So, I'm trying to run your sample images, and Python 2 works while Python 3 doesn't:
$ docker build -t sample-2 python2/
Sending build context to Docker daemon 4.608 kB
Step 1 : FROM markadams/chromium-xvfb-py2:latest-onbuild
# Executing 3 build triggers...
Step 1 : COPY requirements.txt /usr/src/app/requirements.txt
---> Using cache
Step 1 : RUN pip install -r requirements.txt
---> Using cache
Step 1 : COPY . /usr/src/app
---> Using cache
---> 477e657c73e4
Step 2 : RUN mkdir test-results
---> Using cache
---> 3d1115ee728b
Successfully built 3d1115ee728b
$ docker run sample-2
============================= test session starts ==============================
platform linux2 -- Python 2.7.9, pytest-3.0.6, py-1.4.32, pluggy-0.4.0
rootdir: /usr/src/app, inifile: setup.cfg
collected 1 items
test_google.py .
--------- generated xml file: /usr/src/app/test-results/results.py.xml ---------
=========================== 1 passed in 2.61 seconds ===========================
$ docker build -t sample-3 python3/
Sending build context to Docker daemon 4.608 kB
Step 1 : FROM markadams/chromium-xvfb-py3:latest-onbuild
# Executing 3 build triggers...
Step 1 : COPY requirements.txt /usr/src/app/requirements.txt
---> Using cache
Step 1 : RUN pip3 install -r requirements.txt
---> Using cache
Step 1 : COPY . /usr/src/app
---> Using cache
---> a503c017e9ba
Step 2 : RUN mkdir test-results
---> Using cache
---> 57808ed4257e
Successfully built 57808ed4257e
$ docker run sample-3
============================= test session starts ==============================
platform linux -- Python 3.4.2, pytest-3.0.6, py-1.4.32, pluggy-0.4.0
rootdir: /usr/src/app, inifile: setup.cfg
collected 1 items
test_google.py FE
--------- generated xml file: /usr/src/app/test-results/results.py.xml ---------
==================================== ERRORS ====================================
__ ERROR at teardown of ExampleTests.test_google_title_matches_correct_value ___
self = <test_google.ExampleTests testMethod=test_google_title_matches_correct_value>
def tearDown(self):
> self.driver.close()
test_google.py:15:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.4/dist-packages/selenium/webdriver/remote/webdriver.py:510: in close
self.execute(Command.CLOSE)
/usr/local/lib/python3.4/dist-packages/selenium/webdriver/remote/webdriver.py:234: in execute
response = self.command_executor.execute(driver_command, params)
/usr/local/lib/python3.4/dist-packages/selenium/webdriver/remote/remote_connection.py:408: in execute
return self._request(command_info[0], url, body=data)
/usr/local/lib/python3.4/dist-packages/selenium/webdriver/remote/remote_connection.py:439: in _request
self._conn.request(method, parsed_url.path, body, headers)
/usr/lib/python3.4/http/client.py:1090: in request
self._send_request(method, url, body, headers)
/usr/lib/python3.4/http/client.py:1128: in _send_request
self.endheaders(body)
/usr/lib/python3.4/http/client.py:1086: in endheaders
self._send_output(message_body)
/usr/lib/python3.4/http/client.py:924: in _send_output
self.send(msg)
/usr/lib/python3.4/http/client.py:859: in send
self.connect()
/usr/lib/python3.4/http/client.py:836: in connect
self.timeout, self.source_address)
/usr/lib/python3.4/socket.py:509: in create_connection
raise err
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
address = ('127.0.0.1', '43205'), timeout = <object object at 0x7f80cb82d0e0>
source_address = None
def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT,
source_address=None):
"""Connect to *address* and return the socket object.
Convenience function. Connect to *address* (a 2-tuple ``(host,
port)``) and return the socket object. Passing the optional
*timeout* parameter will set the timeout on the socket instance
before attempting to connect. If no *timeout* is supplied, the
global default timeout setting returned by :func:`getdefaulttimeout`
is used. If *source_address* is set it must be a tuple of (host, port)
for the socket to bind as a source address before making the connection.
An host of '' or port 0 tells the OS to use the default.
"""
host, port = address
err = None
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
af, socktype, proto, canonname, sa = res
sock = None
try:
sock = socket(af, socktype, proto)
if timeout is not _GLOBAL_DEFAULT_TIMEOUT:
sock.settimeout(timeout)
if source_address:
sock.bind(source_address)
> sock.connect(sa)
E ConnectionRefusedError: [Errno 111] Connection refused
/usr/lib/python3.4/socket.py:500: ConnectionRefusedError
=================================== FAILURES ===================================
_____________ ExampleTests.test_google_title_matches_correct_value _____________
self = <test_google.ExampleTests testMethod=test_google_title_matches_correct_value>
def test_google_title_matches_correct_value(self):
> self.driver.get("http://www.google.com")
test_google.py:11:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.4/dist-packages/selenium/webdriver/remote/webdriver.py:248: in get
self.execute(Command.GET, {'url': url})
/usr/local/lib/python3.4/dist-packages/selenium/webdriver/remote/webdriver.py:234: in execute
response = self.command_executor.execute(driver_command, params)
/usr/local/lib/python3.4/dist-packages/selenium/webdriver/remote/remote_connection.py:408: in execute
return self._request(command_info[0], url, body=data)
/usr/local/lib/python3.4/dist-packages/selenium/webdriver/remote/remote_connection.py:440: in _request
resp = self._conn.getresponse()
/usr/lib/python3.4/http/client.py:1172: in getresponse
response.begin()
/usr/lib/python3.4/http/client.py:351: in begin
version, status, reason = self._read_status()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <http.client.HTTPResponse object at 0x7f80c80939e8>
def _read_status(self):
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
if len(line) > _MAXLINE:
raise LineTooLong("status line")
if self.debuglevel > 0:
print("reply:", repr(line))
if not line:
# Presumably, the server closed the connection before
# sending a valid response.
> raise BadStatusLine(line)
E http.client.BadStatusLine: ''
/usr/lib/python3.4/http/client.py:321: BadStatusLine
============================ pytest-warning summary ============================
WC1 None [pytest] section in setup.cfg files is deprecated, use [tool:pytest] instead.
============= 1 failed, 1 pytest-warnings, 1 error in 1.86 seconds =============
This is coming from an Ubuntu 16.04 machine, with Docker version:
$ docker version
Client:
Version: 1.12.3
API version: 1.24
Go version: go1.6.2
Git commit: 6b644ec
Built: Mon, 19 Dec 2016 09:20:48 +1300
OS/Arch: linux/amd64
Server:
Version: 1.12.3
API version: 1.24
Go version: go1.6.2
Git commit: 6b644ec
Built: Mon, 19 Dec 2016 09:20:48 +1300
OS/Arch: linux/amd64
Link to https://github.com/mark-adams/docker-chromium-xvfb/blob/master/images/base/xvfb-chromium on the readme.md is incorrect.
Hey, I'm struggling to make chrome start and found your repo so I thought to give it a try.
Unfortunately it doesn't seem to work :(
emmenko: ~/dev/src/docker-chromium-xvfb/samples/js (master)
$ docker run -it --rm -v $(pwd):/src -w /src markadams/chromium-xvfb-js
npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
npm info pretest [email protected]
npm info test [email protected]
> [email protected] test /src
> ./node_modules/karma/bin/karma start
INFO [karma]: Karma v0.12.37 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
WARN [launcher]: Chrome have not captured in 60000 ms, killing.
INFO [launcher]: Trying to start Chrome again (1/2).
WARN [launcher]: Chrome have not captured in 60000 ms, killing.
INFO [launcher]: Trying to start Chrome again (2/2).
WARN [launcher]: Chrome have not captured in 60000 ms, killing.
ERROR [launcher]: Chrome failed 2 times (timeout). Giving up.
npm info [email protected] Failed to exec test script
npm ERR! Test failed. See above for more details.
Any idea what's wrong?
using the base image, should it be possible for other type of application? for example in my case, I'm using Golang and chromedp.
currently I'm trying this Dockerfile
FROM golang:1.11-alpine as builder
WORKDIR /app
COPY go.mod .
COPY go.sum .
RUN apk add --no-cache ca-certificates git
# Get dependancies - will also be cached if we won't change mod/sum
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOARCH=amd64 go install -installsuffix "static" ./cmd/worker/app/...
FROM markadams/chromium-xvfb
COPY --from=builder /go/bin /bin
ENTRYPOINT ["/bin/app"]
The links to the docker hub seem to be broken for me.
The README states the following link: https://registry.hub.docker.com/u/markadams/chromium-xvfb-py3/
However, this one only shows the header and footer of the docker hub page to me, with the body being white.
This link is working for me: https://hub.docker.com/r/markadams/chromium-xvfb-py3/
Hello there.
Trying Docker and your image for the first time, so please bear with, I may have not got it right
So here is what I've done after installing Docker on Ubuntu and installed your image
sudo docker run -i -t markadams/chromium-xvfb /bin/bash
after what I have checked the Chromium browser
root@6f8cc76b7173:/app# which chromium-browser
/usr/bin/chromium-browser
root@6f8cc76b7173:/app# ls -al /usr/bin/chromium-browser
lrwxrwxrwx 1 root root 22 Apr 7 19:30 /usr/bin/chromium-browser -> /usr/bin/xvfb-chromium
root@6f8cc76b7173:/app# chromium-browser
[119:119:0414/140658:ERROR:browser_main_loop.cc(217)] Running without the SUID sandbox! See https://chromium.googlesource.com/chromium/src/+/master/docs/linux_suid_sandbox_development.md for more information on developing with the sandbox on.
Xlib: extension "RANDR" missing on display ":99".
[130:130:0414/140659:ERROR:image_metadata_extractor.cc(114)] Couldn't load libexif. libexif.so.12: cannot open shared object file: No such file or directory
[119:132:0414/140659:ERROR:bus.cc(432)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
[119:132:0414/140659:ERROR:bus.cc(432)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
Xlib: extension "RANDR" missing on display ":99".
[119:119:0414/140659:ERROR:desktop_window_tree_host_x11.cc(891)] Not implemented reached in virtual void views::DesktopWindowTreeHostX11::InitModalType(ui::ModalType)
[161:161:0414/140659:ERROR:sandbox_linux.cc(334)] InitializeSandbox() called with multiple threads in process gpu-process
[119:143:0414/140659:ERROR:browser_gpu_channel_host_factory.cc(145)] Failed to create channel.
Note the extension "RANDR" missing on display ":99".
then Couldn't load libexif
and Failed to connect to socket
are these none critical errors?
In my case, I use vue and vue-cli as 4.0.0 version.
When exec "vue-cli-service build" to build, vue-cli will check chrome version with "chrome --version", so build process will wait and timeout.
expect: chrome --version log the version and not wait.
I expect this command to print out the HTML of a website:
docker-chromium-xvfb/images/base $ docker build -t chromium-xvfb . && docker run --rm --security-opt seccomp=unconfined chromium-xvfb /usr/bin/google-chrome --disable-gpu http://google.com
Instead, it just hangs. The run
command outputs this information:
Xlib: extension "RANDR" missing on display ":99".
[6:17:0404/164119.237190:ERROR:bus.cc(427)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
Xlib: extension "RANDR" missing on display ":99".
and the image has to be killed via docker kill
. I can get rid of the dbus error with:
docker run --rm --security-opt seccomp=unconfined chromium-xvfb bash -c 'service dbus start && /usr/bin/google-chrome --disable-gpu http://google.com'
But I still just get a hung docker image. I've tested replacing http://google.com with a local URL and --net=host
to ensure that it's not hitting the server, and it's not.
Any ideas for how I could get this to work, or to debug it further?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.