#!/bin/bash

source "$(dirname "$0")/setup.sh"

CHROMEDRIVER_LINUX_32_URL='http://chromedriver.storage.googleapis.com/2.24/chromedriver_linux32.zip'
CHROMEDRIVER_LINUX_64_URL='http://chromedriver.storage.googleapis.com/2.24/chromedriver_linux64.zip'
CHROMEDRIVER_MAC_URL='http://chromedriver.storage.googleapis.com/2.24/chromedriver_mac64.zip'

if [[ "${SV_S_BINARIES}" == 'Linux64'  ]]; then
   CHROMEDRIVER_URL=$CHROMEDRIVER_LINUX_64_URL
elif [[ "${SV_S_BINARIES}" == 'Linux'  ]]; then
   CHROMEDRIVER_URL=$CHROMEDRIVER_LINUX_32_URL
elif [[ "${SV_S_BINARIES}" == 'Mac'  ]]; then
   CHROMEDRIVER_URL=$CHROMEDRIVER_MAC_URL
else
   echo "OS not supported"
   exit 1
fi

mkdir -p $SEL_DIR
rm -rf $SEL_DIR/chromedriver*
cd $SEL_DIR

if [ `which wget` ]; then
  wget $CHROMEDRIVER_URL
elif [ `which curl` ]; then
  curl -O $CHROMEDRIVER_URL
else
  echo "No wget or curl in path"
  exit 1
fi

unzip chromedriver*.zip
rm chromedriver*.zip

