forked from open-xml-templating/docxtemplater
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webdriver.bash
executable file
·65 lines (60 loc) · 1.19 KB
/
webdriver.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
63
64
#!/usr/bin/env bash
set -euo pipefail
pid=""
cleanup() {
if [ "$pid" != "" ]
then
while true
do
kill "$pid" 1>/dev/null 2>&1 || break
sleep 1
done
fi
}
trap "cleanup" EXIT INT
BROWSER="${BROWSER:-CHROME|FIREFOX|}"
PATH="$PATH:./node_modules/.bin/"
if grep '|' <<<"$BROWSER" >/dev/null
then
while read -r -d '|' browser
do
echo "$browser"
BROWSER="$browser" ./webdriver.bash
done <<<"$BROWSER"
exit 0
fi
port4444used() {
netstat -tnlp 2>/dev/null | grep 4444 >/dev/null
}
if [ "$BROWSER" != "SAUCELABS" ]
then
if port4444used
then
echo "Using existing selenium"
else
if ! [ -d node_modules/selenium-standalone/.selenium ]
then
mkdir -p "$HOME/tmp/"
if [ -d "$HOME/tmp/.selenium" ]
then
echo "Copying selenium from cache"
cp -r "$HOME/tmp/.selenium" node_modules/selenium-standalone/.selenium
else
echo "Installing selenium"
selenium-standalone install
cp -r node_modules/selenium-standalone/.selenium "$HOME/tmp/.selenium"
fi
fi
echo "Starting selenium"
selenium-standalone start -- -log /tmp/protractor.log &
pid="$!"
while ! port4444used;
do
sleep 0.5
done
fi
node webdriver.js
exit "$?"
else
bash webdriver-saucelabs.bash
fi