Skip to content

Commit 88b8f45

Browse files
more fixes, updated README
1 parent a7f4aa0 commit 88b8f45

File tree

5 files changed

+70
-27
lines changed

5 files changed

+70
-27
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/vendor/
2-
.idea/
2+
.idea/
3+
nohup.out

README.md

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,43 @@
11
# selenium-server
2-
selenium-server
2+
3+
This is a simple package to easily run Selenium with Chrome driver.
4+
5+
It does not contain the binaries, instead it will download them on first run.
6+
7+
It has only been run and tested on Linux.
8+
9+
To install it simply add
10+
11+
`"edmondscommerce/selenium-server": "~1"`
12+
13+
To your composer.json file and then run composer update
14+
15+
16+
## Running
17+
18+
`bin/selenium-run.bash` To run Selenium in a terminal. You can stop the Selenium process as required by hitting [ctrl]+[c]
19+
20+
## Running in the background
21+
22+
`bin/selenium-background-run.bash`
23+
24+
This will run the process in the background using nohup
25+
26+
## Stopping the background process
27+
28+
`bin/selenium-stop.bash`
29+
30+
This will find a Selenium process that is running in the background and kill it
31+
32+
33+
## Firefox / Chrome
34+
35+
This process uses Chrome by default.
36+
37+
If you want to use it with Firefox, you need to append the `firefox` flag, eg
38+
39+
`bin/selenium-run.bash firefox`
40+
41+
Or
42+
43+
`bin/selenium-background-run.bash firefox`

bin/selenium-background-run.bash

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli
66
[[ $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
77
done
88
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
9+
cd $DIR
910

1011
echo '' > nohup.out
11-
nohup $DIR/selenium-run.bash "$@" &
12-
sleep 1
12+
nohup ./selenium-run.bash "$@" &
13+
sleep 2
1314

1415
cat nohup.out
1516
echo "

bin/selenium-run.bash

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
#!/bin/bash
2+
#set -x
3+
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+
211
SOURCE="${BASH_SOURCE[0]}"
312
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
413
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
@@ -12,12 +21,7 @@ then
1221
echo "Failed cd-ing into the the binaries folder, aborting"
1322
exit 1
1423
fi
15-
MAJOR_VERSION=2.44
16-
VERSION=${MAJOR_VERSION}.0
17-
JAR_FILE=selenium-server-standalone-${VERSION}.jar
1824

19-
CHROMEDRIVER_VERSION=2.14
20-
CHROMEDRIVER_FILE=chromedriver-${CHROMEDRIVER_VERSION}
2125

2226
## Host File bug sanity check
2327
grep '127.0.0.1 localhost' /etc/hosts > /dev/null
@@ -77,17 +81,8 @@ fi
7781

7882
echo "Starting Selenium"
7983

80-
echo "Checking if already running:"
81-
h=$(pgrep -f selenium-server)
82-
if [[ -n $h ]]; then
83-
echo "found running instance, killing that now"
84-
kill $h
85-
while [[ -n $h ]]; do
86-
sleep 1
87-
h=$(pgrep -f selenium-server)
88-
done
89-
fi
90-
echo "done"
84+
echo "Killing if already running:"
85+
source $DIR/selenium-stop.bash
9186

9287

9388
if [[ "$@" =~ .*firefox.* ]]

bin/selenium-stop.bash

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
#!/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
2+
SELENIUM_PROCESS_GREP=selenium-server-standalone
3+
4+
h=$(pgrep -f ${SELENIUM_PROCESS_GREP} )
5+
if [[ -n $h ]]; then
6+
echo "Killing PID $h"
7+
kill $h
8+
while [[ -n $h ]]; do
9+
sleep 1
10+
h=$(pgrep -f ${SELENIUM_PROCESS_GREP} )
11+
done
912
echo "done"
13+
else
14+
echo "No Selenium process found"
1015
fi

0 commit comments

Comments
 (0)