-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathselenium-run.bash
executable file
·62 lines (56 loc) · 1.61 KB
/
selenium-run.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env bash
source="${BASH_SOURCE[0]}"
while [ -h "$source" ]; do # resolve $SOURCE until the file is no longer a symlink
dir="$( cd -P "$( dirname "$source" )" && pwd )"
source="$(readlink "$source")"
[[ $source != /* ]] && source="$dir/$source" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
dir="$( cd -P "$( dirname "$source" )" && pwd )"
cd $dir;
set -e
set -u
set -o pipefail
standardIFS="$IFS"
IFS=$'\n\t'
echo "
===========================================
$(hostname) $0 $@
===========================================
"
# Error Handling
backTraceExit () {
local err=$?
set +o xtrace
local code="${1:-1}"
printf "\n\nError in ${BASH_SOURCE[1]}:${BASH_LINENO[0]}. '${BASH_COMMAND}'\n\n exited with status: \n\n$err\n\n"
# Print out the stack trace described by $function_stack
if [ ${#FUNCNAME[@]} -gt 2 ]
then
echo "Call tree:"
for ((i=1;i<${#FUNCNAME[@]}-1;i++))
do
echo " $i: ${BASH_SOURCE[$i+1]}:${BASH_LINENO[$i]} ${FUNCNAME[$i]}(...)"
done
fi
echo "Exiting with status ${code}"
exit "${code}"
}
trap 'backTraceExit' ERR
set -o errtrace
jarFile=${1:-'false'}
if [[ "false" == "$jarFile" ]]
then
source ./check-deps.bash
source ./download-binaries.bash
fi
echo "Now Starting Selenium"
echo "Killing if already running:"
bash $dir/selenium-stop.bash
if [[ "$@" =~ .*firefox.* ]]
then
echo "starting firefox selenium"
java -jar $jarFile
else
echo "starting chrome selenium"
java -Dwebdriver.chrome.driver=${chromedriverFile} -jar $jarFile
fi