Last active
January 3, 2016 13:59
-
-
Save elgalu/8473508 to your computer and use it in GitHub Desktop.
ChromeDriver headless testing on debian-based unix systemsBased on: https://www.exratione.com/2013/12/angularjs-headless-end-to-end-testing-with-protractor-and-selenium/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get install xvfb | |
sudo vim /etc/init.d/xvfb | |
sudo chown root:root /etc/init.d/xvfb | |
sudo chmod a+x /etc/init.d/xvfb | |
sudo update-rc.d xvfb defaults | |
# The Ubuntu server can now run software with a GUI in a headless mode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# sudo vim /etc/init.d/xvfb | |
# | |
# Xvfb init script for Debian-based distros. | |
# | |
# The display number used must match the DISPLAY environment variable used | |
# for other applications that will use Xvfb. e.g. ':10'. | |
# | |
# From: https://github.com/gmonfort/xvfb-init/blob/master/Xvfb | |
# | |
### BEGIN INIT INFO | |
# Provides: xvfb | |
# Required-Start: $remote_fs $syslog | |
# Required-Stop: $remote_fs $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Start/stop custom Xvfb | |
# Description: Enable service provided by xvfb | |
### END INIT INFO | |
NAME=Xvfb | |
DESC="$NAME - X Virtual Frame Buffer" | |
SCRIPTNAME=/etc/init.d/$NAME | |
XVFB=/usr/bin/Xvfb | |
PIDFILE=/var/run/${NAME}.pid | |
# Using -extension RANDR doesn't seem to work anymore. Firefox complains | |
# about not finding extension RANDR whether or not you include it here. | |
# Fortunately this is a non-fatal warning and doesn't stop Firefox from working. | |
XVFB_ARGS=":10 -extension RANDR -noreset -ac -screen 10 1400x968x16" | |
set -e | |
if [ `id -u` -ne 0 ]; then | |
echo "You need root privileges to run this script" | |
exit 1 | |
fi | |
[ -x $XVFB ] || exit 0 | |
. /lib/lsb/init-functions | |
[ -r /etc/default/Xvfb ] && . /etc/default/Xvfb | |
case "$1" in | |
start) | |
log_daemon_msg "Starting $DESC" "$NAME" | |
if start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE \ | |
--background --make-pidfile --exec $XVFB -- $XVFB_ARGS ; then | |
log_end_msg 0 | |
else | |
log_end_msg 1 | |
fi | |
log_end_msg $? | |
;; | |
stop) | |
log_daemon_msg "Stopping $DESC" "$NAME" | |
start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE --retry 5 | |
if [ $? -eq 0 ] && [ -f $PIDFILE ]; then | |
/bin/rm -rf $PIDFILE | |
fi | |
log_end_msg $? | |
;; | |
restart|force-reload) | |
log_daemon_msg "Restarting $DESC" "$NAME" | |
$0 stop && sleep 2 && $0 start | |
;; | |
status) | |
status_of_proc -p $PIDFILE $XVFB $NAME && exit 0 || exit $? | |
;; | |
*) | |
log_action_msg "Usage: ${SCRIPTNAME} {start|stop|status|restart|force-reload}" | |
exit 2 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment