Skip to content

Instantly share code, notes, and snippets.

@jakzal
Last active February 16, 2018 17:32
Show Gist options
  • Select an option

  • Save jakzal/8583518 to your computer and use it in GitHub Desktop.

Select an option

Save jakzal/8583518 to your computer and use it in GitHub Desktop.

Revisions

  1. jakzal revised this gist Jan 23, 2014. 1 changed file with 5 additions and 4 deletions.
    9 changes: 5 additions & 4 deletions selenium.sh
    Original file line number Diff line number Diff line change
    @@ -3,6 +3,7 @@
    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
    @@ -14,11 +15,11 @@ start_hub() {
    }

    start_nodes() {
    nodes=$(grep "^processor" /proc/cpuinfo | sort -u | wc -l)
    nodes=$( [ $(which nproc) ] && nproc || sysctl -n hw.ncpu)
    for i in $(seq 1 $nodes); do
    port=$(expr 5557 + $i)
    echo "Starting node "$i
    java -jar selenium-server-standalone.jar -role node -port $port -browser browserName=phantomjs > /dev/null 2>&1 &
    port=$(expr 5555 + $i)
    java -jar selenium-server-standalone.jar -role node -port $port $NODE_OPTIONS > /dev/null 2>&1 &
    sleep 1
    done
    }
    @@ -30,7 +31,7 @@ start() {
    }

    stop() {
    ps ax o'pid command' | grep selenium-server | grep -v grep | awk '{print $1}' | tr "\n" ' ' | xargs kill -9 &> /dev/null
    ps ax -o'pid command' | grep selenium-server | grep -v grep | awk '{print $1}' | tr "\n" ' ' | xargs kill -9 &> /dev/null
    }

    help() {
  2. jakzal revised this gist Jan 23, 2014. 1 changed file with 8 additions and 2 deletions.
    10 changes: 8 additions & 2 deletions selenium.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    #!/bin/sh

    command=$1||"start"
    command=${1:-"help"}

    SELENIUM_VERSION="2.39.0"

    @@ -33,4 +33,10 @@ stop() {
    ps ax o'pid command' | grep selenium-server | grep -v grep | awk '{print $1}' | tr "\n" ' ' | xargs kill -9 &> /dev/null
    }

    $command
    help() {
    echo "Available actions: "
    compgen -A function | tr "\\n" " "
    echo
    }

    $command
  3. jakzal revised this gist Jan 23, 2014. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions selenium.sh
    Original file line number Diff line number Diff line change
    @@ -10,15 +10,15 @@ download() {

    start_hub() {
    echo "Starting the hub"
    java -jar selenium-server-standalone.jar -role hub &> /dev/null &
    java -jar selenium-server-standalone.jar -role hub > /dev/null 2>&1 &
    }

    start_nodes() {
    nodes=$(grep "^processor" /proc/cpuinfo | sort -u | wc -l)
    for i in $(seq 1 $nodes); do
    echo "Starting node "$i
    port=$(expr 5557 + $i)
    java -jar selenium-server-standalone.jar -role node -port $port -browser browserName=phantomjs &> /dev/null &
    echo "Starting node "$i
    java -jar selenium-server-standalone.jar -role node -port $port -browser browserName=phantomjs > /dev/null 2>&1 &
    sleep 1
    done
    }
  4. jakzal created this gist Jan 23, 2014.
    36 changes: 36 additions & 0 deletions selenium.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    #!/bin/sh

    command=$1||"start"

    SELENIUM_VERSION="2.39.0"

    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 &
    }

    start_nodes() {
    nodes=$(grep "^processor" /proc/cpuinfo | sort -u | wc -l)
    for i in $(seq 1 $nodes); do
    echo "Starting node "$i
    port=$(expr 5557 + $i)
    java -jar selenium-server-standalone.jar -role node -port $port -browser browserName=phantomjs &> /dev/null &
    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
    }

    $command