Last active
February 16, 2018 17:32
-
-
Save jakzal/8583518 to your computer and use it in GitHub Desktop.
Selenium grid runner
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/sh | |
command=${1:-"help"} | |
SELENIUM_VERSION="2.39.0" | |
NODE_OPTIONS="-browser browserName=phantomjs" | |
download() { | |
[ -f selenium-server-standalone.jar ] || wget http://selenium.googlecode.com/files/selenium-server-standalone-${SELENIUM_VERSION}.jar -Oselenium-server-standalone.jar | |
} | |
start_hub() { | |
echo "Starting the hub" | |
java -jar selenium-server-standalone.jar -role hub > /dev/null 2>&1 & | |
} | |
start_nodes() { | |
nodes=$( [ $(which nproc) ] && nproc || sysctl -n hw.ncpu) | |
for i in $(seq 1 $nodes); do | |
echo "Starting node "$i | |
port=$(expr 5555 + $i) | |
java -jar selenium-server-standalone.jar -role node -port $port $NODE_OPTIONS > /dev/null 2>&1 & | |
sleep 1 | |
done | |
} | |
start() { | |
download | |
start_hub | |
start_nodes | |
} | |
stop() { | |
ps ax -o'pid command' | grep selenium-server | grep -v grep | awk '{print $1}' | tr "\n" ' ' | xargs kill -9 &> /dev/null | |
} | |
help() { | |
echo "Available actions: " | |
compgen -A function | tr "\\n" " " | |
echo | |
} | |
$command |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment