Created
June 3, 2011 17:49
-
-
Save terrancesnyder/1006777 to your computer and use it in GitHub Desktop.
Selenium Grid Client for headless Linux
This file contains hidden or 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 | |
# _____ __ _ | |
# / ___/___ / /__ ____ (_)_ ______ ___ | |
# \__ \/ _ \/ / _ \/ __ \/ / / / / __ `__ \ | |
# ___/ / __/ / __/ / / / / /_/ / / / / / / | |
# /____/\___/_/\___/_/ /_/_/\__,_/_/ /_/ /_/ | |
# | |
# Provides a shell script which can be used to create | |
# a new selenium rc client. | |
# | |
# The main benefit of this is that we use tightvncserver to | |
# host our selenium client, which can be used to record and | |
# playback all tests run, and also allows running selenium rc | |
# in headless mode on linux (ubuntu). | |
# Requires: | |
# tightvncserver | |
# CURL | |
ACTION=$1 | |
HOST=$2 | |
PORT=$3 | |
IP=`hostname` | |
SCRIPT=$(readlink -f $0) | |
DIRECTORY=`dirname $SCRIPT` | |
start_arg_check() { | |
if [ -z "$ACTION" -o -z "$HOST" -o -z "$PORT" ]; then | |
usage | |
exit 0 | |
fi | |
if [ ! -d "$DIRECTORY/logs" ]; then | |
mkdir $DIRECTORY/logs | |
fi | |
} | |
usage() { | |
echo "" | |
echo "Usage: " | |
echo " $0 start [your.gridserver.com] [port]" | |
echo " $0 stop" | |
echo "" | |
echo "Examples:" | |
echo " $0 start 127.0.0.1 4545" | |
echo " $0 stop" | |
echo "" | |
} | |
if [ -z "$ACTION" ]; then | |
usage | |
exit 0 | |
fi | |
case $ACTION in | |
start) | |
start_arg_check | |
echo "Starting selenium grid client on $PORT..." | |
$DIRECTORY/ephemeral-x.sh -x "tightvncserver -depth 24 -geometry 1024x768" \ | |
ant -f $DIRECTORY/build.xml \ | |
-Dport="$PORT" \ | |
-Denvironment=*chrome \ | |
-Dhost="$IP" \ | |
-DhubURL=http://$HOST:4444/ \ | |
launch-remote-control 2>$DIRECTORY/logs/"$PORT"_error.log 1>$DIRECTORY/logs/"$PORT"_console.log & | |
echo "(success)" | |
;; | |
stop) | |
echo "Killing all firefox browsers..." | |
ps aux | grep firefox | grep -v grep | awk '{print $2}' | xargs kill -9 > /dev/null 2>&1 | |
echo "Stopping selenium grid client..." | |
ps aux | grep chrome | grep -v grep | awk '{print $2}' | xargs kill -9 > /dev/null 2>&1 | |
echo "Killing Xvfb..." | |
ps aux | grep Xvfb | grep -v grep | awk '{print $2}' | xargs kill -9 > /dev/null 2>&1 | |
echo "(success)" | |
;; | |
esac | |
exit 0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment