|
| 1 | +#!/bin/bash |
| 2 | +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
| 3 | +cd $DIR/../binaries/ |
| 4 | +MAJOR_VERSION=2.44 |
| 5 | +VERSION=${MAJOR_VERSION}.0 |
| 6 | +JAR_FILE=selenium-server-standalone-${VERSION}.jar |
| 7 | + |
| 8 | +CHROMEDRIVER_VERSION=2.14 |
| 9 | +CHROMEDRIVER_FILE=chromedriver-${CHROMEDRIVER_VERSION} |
| 10 | + |
| 11 | +## Host File bug sanity check |
| 12 | +grep '127.0.0.1 localhost' /etc/hosts > /dev/null |
| 13 | +if [[ $? != 0 ]] |
| 14 | +then |
| 15 | + echo " |
| 16 | +
|
| 17 | + WARNING |
| 18 | +
|
| 19 | + Selenium won't work unless your hosts file localhost aliases start explictly with: |
| 20 | +
|
| 21 | + 127.0.0.1 localhost ...other aliases here |
| 22 | +
|
| 23 | + Please edit your hosts file and try again |
| 24 | +
|
| 25 | + See: |
| 26 | + https://code.google.com/p/selenium/issues/detail?id=3280 |
| 27 | +
|
| 28 | +Your hosts line is: |
| 29 | + " |
| 30 | + grep '127.0.0.1' /etc/hosts |
| 31 | + echo; |
| 32 | + exit 1 |
| 33 | +fi |
| 34 | + |
| 35 | +if [ ! -f $JAR_FILE ] |
| 36 | +then |
| 37 | + echo "Selenium JAR file not found - trying to wget the file" |
| 38 | + DOWNLOAD_URL="http://selenium-release.storage.googleapis.com/${MAJOR_VERSION}/selenium-server-standalone-${VERSION}.jar" |
| 39 | + echo $DOWNLOAD_URL |
| 40 | + wget $DOWNLOAD_URL |
| 41 | + if [[ $? != 0 ]] |
| 42 | + then |
| 43 | + echo "Failed downloading, please grab it manually" |
| 44 | + exit 1 |
| 45 | + fi |
| 46 | +fi |
| 47 | + |
| 48 | +if [ ! -f $CHROMEDRIVER_FILE ] |
| 49 | +then |
| 50 | + echo "Chromedriver file not found - trying to wget the file" |
| 51 | + DOWNLOAD_URL="http://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip" |
| 52 | + echo $DOWNLOAD_URL |
| 53 | + wget $DOWNLOAD_URL |
| 54 | + if [[ $? != 0 ]] |
| 55 | + then |
| 56 | + echo "Failed downloading, please grab it manually" |
| 57 | + exit 1 |
| 58 | + fi |
| 59 | + if [ -f chromedriver ] |
| 60 | + then |
| 61 | + rm chromedriver |
| 62 | + fi |
| 63 | + unzip chromedriver_linux64.zip |
| 64 | + mv chromedriver $CHROMEDRIVER_FILE |
| 65 | +fi |
| 66 | + |
| 67 | +echo "Starting Selenium" |
| 68 | + |
| 69 | +echo "Checking if already running:" |
| 70 | +h=$(pgrep -f selenium-server) |
| 71 | +if [[ -n $h ]]; then |
| 72 | + echo "found running instance, killing that now" |
| 73 | + kill $h |
| 74 | + while [[ -n $h ]]; do |
| 75 | + sleep 1 |
| 76 | + h=$(pgrep -f selenium-server) |
| 77 | + done |
| 78 | +fi |
| 79 | +echo "done" |
| 80 | + |
| 81 | + |
| 82 | +if [[ "$@" =~ .*firefox.* ]] |
| 83 | +then |
| 84 | + echo "starting firefox selenium |
| 85 | + " |
| 86 | + java -jar $JAR_FILE |
| 87 | +else |
| 88 | + echo "starting chrome selenium |
| 89 | + " |
| 90 | + java -jar $JAR_FILE -Dwebdriver.chrome.driver=${CHROMEDRIVER_FILE} |
| 91 | +fi |
0 commit comments