Error running headless Chromium on Ubuntu - chromium

I installed Chromium 59.0, and I'm trying to run it in headless mode using the following command:
sudo /opt/google/chrome/chrome --headless --disable-gpu --no-sandbox
but I'm getting the following errors:
[0512/174717.638937:WARNING:audio_manager.cc(295)] Multiple instances of AudioManager detected
[0512/174717.639027:WARNING:audio_manager.cc(254)] Multiple instances of AudioManager detected
Has anyone encountered this and found a way to get past it?

I encountered the exact same thing under dockerized ubuntu running karma.js tests.
You will need to have pulseaudio or similar running.
Try:
apt-get install pulseaudio
And before you run chrome
pulseaudio --daemonize
You can see it in my docker-entrypoint.sh:
https://github.com/codeclou/docker-nodejs-chrome-xvfb
When running with docker you will need to run docker with:
--shm-size=128M
Since chrome will complain about small /dev/shm which is 64MB by default.

Related

How to run flatpak app as a systemd service?

I'm using playwright to run automated testing on CentOS 8.
Node script are run as systemd services.
Chromium is used from the rpm package.
But chromium from rpm package has problems with video codec support.
I installed chromium from flatpak and tried to run it...
After the first failure, I went to github playwright repo.
Then I created another question, but already in the flatpack repo.
In short, when I try to start chromium from flatpak from script that is running as a systemd service, I get an error:
Cannot autolaunch D-Bus without X11 $DISPLAY
(zenity:8): Gtk-WARNING **: 17:13:28.767: cannot open display:
As far as I understand, I need to somehow make sure that the script running as a service has a dbus... How to do it?
You need to set correct Environment= inside your unit or export all required variables using
systemctl --user import-environment DISPLAY XAUTHORITY
if command -v dbus-update-activation-environment >/dev/null 2>&1; then
dbus-update-activation-environment DISPLAY XAUTHORITY
fi
See
https://unix.stackexchange.com/a/653101
https://wiki.archlinux.org/title/systemd/User#Environment_variables
After that, even with a basic unit below
~/.config/systemd/user/chromium.service
[Unit]
Description=Chromium
[Service]
ExecStart=/usr/bin/flatpak run org.chromium.Chromium
ExecStop=/usr/bin/flatpak kill org.chromium.Chromium
[Install]
WantedBy=default.target
systemctl --user start chromium will open your browser

Cannot start Chromium

I am trying to start Chromium 49.0.2623.108 on Ubuntu 15.10 installed on my ODROID-XU4. It used to work all the time but from one day to the next Chromium will not start. When I try to run it via terminal I get:
~$ chromium-browser
[3813:3840:0101/015306:ERROR:cert_verify_proc_nss.cc(925)] CERT_PKIXVerifyCert for www.google.com failed err=-8181
[3813:3840:0101/015306:ERROR:cert_verify_proc_nss.cc(925)] CERT_PKIXVerifyCert for translate.googleapis.com failed err=-8181
[3813:3839:0101/015306:ERROR:cert_verify_proc_nss.cc(925)] CERT_PKIXVerifyCert for clients2.google.com failed err=-8181
Segmentation fault
odroid#odroid:~$ libGL error: unable to load driver: exynos_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: exynos
[3866:3866:0101/015307:ERROR:sandbox_linux.cc(334)] InitializeSandbox() called with multiple threads in process gpu-process
Any idea what I can do?
I have already tried reinstalling Chromium. That did not solve the issue.
Thanks in advance!
Ok, so it looks like rolling Chromium back to version 45.0.2454.101 works as a temporary solution (although it'd still be great if someone got the newest version to work). To do this, I had to go through the following steps:
Run sudo apt-get remove chromium-browser to remove the broken version of the package
Get the list of available package versions via sudo apt-cache showpkg chromium-browser (at the time of writing, there were two: 50.0.2661.102 (newest) and 45.0.2454.101)
Install the older version, like so: sudo apt-get install chromium-browser=45.0.2454.101-0ubuntu1.1201
(Optional) If you got a dependency error during the previous step, execute these two first: sudo apt-get remove chromium-codecs-ffmpeg-extra and sudo apt-get install chromium-codecs-ffmpeg-extra=45.0.2454.101-0ubuntu1.1201
Chromium should start up fine now
This worked for two of my Odroid XU4's running Ubuntu 15.10 and Chromium 50.0.2661.102 (before the downgrade).
EDIT: looks like this problem affects all ARM-based single board computers, rather than the Odroid XU4 in particular (although the reference to exynos_dri.so might make it look like an Odroid XU4 issue). See here for more information + other ways to rollback to an older version.
EDIT #2: There also seems to be a way to get the newest version to work, but I have not tried this out so I don't know whether it will actually work or not.

Appium does not start with non sudo installation

Platform: Ubuntu 14.10
Appium - 1.3.7
One similar question I had come across -
How to setup Appium in Ubuntu for android
and following suggestion, I install npm via HomeBrew
And eventually, appium execution fails with error -
error: Appium will not work if used or installed with sudo. Please rerun/install as a non-root user. If you had to install Appium using `sudo npm install -g appium`, the solution is to reinstall Node using a method (Homebrew, for example) that doesn't require sudo to install global npm packages.
Is there anything I missed?
Appium allows to run under sudo since 1.2.3: source
apparently I was on wrong directory when invoking invoking appium. I should be in /node-v0.12.2-linux-x64/bin$ and invoke appium.
even though I was in wrong directory, the error message I received was so descriptive (and misleading) that it made me believe that I installed appium in wrong way.

Running selenium-chromedriver using Protractor on linux

I am using protractor to run tests against an Angular application. They work on my OSX environment but not on Linux where TeamCity is trying to run it.
When I run this command on my local OSX environment, it works (tested on my co-workers machine, too):
./node_modules/protractor/bin/protractor protractor.conf.js
Using ChromeDriver directly...
..
Finished in 5.55 seconds
2 tests, 2 assertions, 0 failures
When I run this on a linux machine, or a TeamCity job tries to run it, it fails:
./node_modules/protractor/bin/protractor protractor.conf.js
Using ChromeDriver directly...
/usr/share/TeamCity/buildAgent/work/57bd89f9c9abb5d5/webapp/node_modules/protractor/node_modules/selenium-webdriver/http/util.js:87
Error('Timed out waiting for the WebDriver server at ' + url));
^
Error: Timed out waiting for the WebDriver server at http://127.0.0.1:52959/
at Error (<anonymous>)
at onResponse (/usr/share/TeamCity/buildAgent/work/57bd89f9c9abb5d5/webapp/node_modules/protractor/node_modules/selenium-webdriver/http/util.js:87:11)
at /usr/share/TeamCity/buildAgent/work/57bd89f9c9abb5d5/webapp/node_modules/protractor/node_modules/selenium-webdriver/http/util.js:42:21
at /usr/share/TeamCity/buildAgent/work/57bd89f9c9abb5d5/webapp/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/http/http.js:96:5
at ClientRequest.<anonymous> (/usr/share/TeamCity/buildAgent/work/57bd89f9c9abb5d5/webapp/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:136:7)
at ClientRequest.EventEmitter.emit (events.js:95:17)
at Socket.socketErrorListener (http.js:1547:9)
at Socket.EventEmitter.emit (events.js:95:17)
at net.js:440:14
at process._tickCallback (node.js:415:13)
==== async task ====
WebDriver.createSession()
at Function.webdriver.WebDriver.acquireSession_ (/usr/share/TeamCity/buildAgent/work/57bd89f9c9abb5d5/webapp/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:131:49)
at Function.webdriver.WebDriver.createSession (/usr/share/TeamCity/buildAgent/work/57bd89f9c9abb5d5/webapp/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:111:30)
Attempts to resolve:
I have looked at this issue, but a standalone webdriver server is no solution.
I looked at this issue but my version of selenium-wedriver is 2.42.1, so, not the same bug.
Versions:
$ node --version
v0.10.26
$ ./node_modules/protractor/bin/protractor --version
Version 1.0.0
$ uname -mrs
Linux 3.11.0-15-generic x86_64
Progress Update:
Trying to get the version of chrome-webdriver exposed a problem:
$ ./node_modules/protractor/selenium/chromedriver --version
./node_modules/protractor/selenium/chromedriver: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory
From this I concluded there was a dependency issue and found that Selenium requires Chrome. (more).
I installed Chrome on the Linux box using steps like this:
sudo apt-get install libxss1 libappindicator1 libindicator7
sudo wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome*.deb
This didn't work exactly like that, but after a few back and forths with dependencies and sudo apt-get install I think I got Chrome installed:
$ google-chrome --version
Google Chrome 36.0.1985.143
This made the chromedriver version work:
$ ./node_modules/protractor/selenium/chromedriver --version
ChromeDriver 2.10.267518
However, running Protractor still does not work:
$ ./node_modules/protractor/bin/protractor protractor.conf.js
Using ChromeDriver directly...
/usr/share/TeamCity/buildAgent/work/57bd89f9c9abb5d5/webapp/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/error.js:109
var template = new Error(this.message);
^
UnknownError: unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.10.267518,platform=Linux 3.11.0-15-generic x86_64)
at new bot.Error (/usr/share/TeamCity/buildAgent/work/57bd89f9c9abb5d5/webapp/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/error.js:109:18)
at Object.bot.response.checkResponse (/usr/share/TeamCity/buildAgent/work/57bd89f9c9abb5d5/webapp/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/response.js:106:9)
You need to be able to run Chrome or Firefox headless and for that you'll need to configure Xvfb among other things, otherwise Chrome will fail to launch without a proper $DISPLAY.
You could also use PhantomJS but, IMHO, what good does that to e2e testing since is not a real browser.
This is what I'm successfully using for continuous testing: https://github.com/elgalu/docker-selenium
I had the same problem and it resolved just after installing unity-gtk3-module !!
yum install unity-gtk3-module
Installing:
PackageKit-gtk3-module
Updating:
Installing for dependencies:
PackageKit-glib
adwaita-cursor-theme
adwaita-icon-theme
at-spi2-atk
at-spi2-core
cairo-gobject
colord-libs
gtk3
json-glib
libXevie
libgusb
rest
Updating for dependencies:
glib2
i hope this helps

Is it possible to run selenium scripts using google compute engine?

I would like to run my selenium scripts on the cloud/online/remotely. I have been advised google compute engine could allow this.
It would be appreciated if this could be confirmed and additional steps that will be needed to be given too.
Any other solutions suggested would be appreciated.
The only difference is that your GCE instance doesn't have a display, which is going to be an issue for your browser.
To address this, you'll want to run Selenium using a "Virtual Framebuffer". This is basically a "Fake display".
Here's how you set a Virtual Framebuffer up in Ubuntu:
sudo apt-get install xvfb
sudo Xvfb :10 -ac
Then, before starting your selenium script, just run:
export DISPLAY=:10