Skip to content

Commit a1989c3

Browse files
initial commit
1 parent d6b897c commit a1989c3

File tree

5 files changed

+131
-0
lines changed

5 files changed

+131
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
binaries/*
2+
/vendor/
3+
.idea/

bin/selenium-background-run.bash

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
3+
4+
echo '' > nohup.out
5+
nohup $DIR/../selenium/selenium-run.bash "$@" &
6+
sleep 1
7+
8+
cat nohup.out
9+
echo "
10+
11+
Selenium Running"

bin/selenium-run.bash

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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

bin/selenium-stop.bash

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
SELENIUM_PID=$(pgrep -f selenium-server)
3+
if [[ "" == "$SELENIUM_PID" ]]
4+
then
5+
echo "No Selenium process found"
6+
else
7+
echo "Killing PID $SELENIUM_PID"
8+
kill $SELENIUM_PID
9+
echo "done"
10+
fi

composer.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "edmondscommerce/selenium-server",
3+
"description": "Utilities for installing and running Selenium (with Chromedriver), ideal for use with Behat",
4+
"keywords": ["Selenium", "Behat", "Selenium-Server", "Chromedriver", "Browser Testing"]
5+
"homepage": "https://www.edmondscommerce.co.uk",
6+
"license": "MIT",
7+
"authors": [
8+
{
9+
"name": "edmondscommerce",
10+
"email": "[email protected]"
11+
}
12+
],
13+
"minimum-stability": "dev",
14+
"require": {},
15+
"bin": ["bin/selenium-background-run.bash", "bin/selenium-run.bash", "bin/selenium-stop.bash"]
16+
}

0 commit comments

Comments
 (0)