Skip to content

Commit 79a483b

Browse files
committed
Merge pull request #11 from mdmintz/selenium-grid-overhaul
Selenium Grid overhaul
2 parents d2c6204 + 2e0085a commit 79a483b

File tree

9 files changed

+180
-15
lines changed

9 files changed

+180
-15
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,6 @@ nosetests.xml
3535
# Developer
3636
.project
3737
.pydevproject
38+
39+
# Other
40+
selenium-server-standalone.jar

integrations/docker/docker_setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
setup(
1010
name='seleniumbase',
11-
version='1.1.22',
11+
version='1.1.23',
1212
author='Michael Mintz',
1313
author_email='@mintzworld',
1414
maintainer='Michael Mintz',

integrations/selenium_grid/ReadMe.md

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,22 @@ The Selenium Grid Hub allows you to distribute tests to run in parallel across m
44

55
### Running the Selenium Grid Hub
66

7-
You may need to download selenium-server-standalone-2.50.1.jar (or the latest version) separately. That file is not present with this repository to save space. You can download that file from here:
8-
* http://docs.seleniumhq.org/download/
9-
or here:
10-
* http://selenium-release.storage.googleapis.com/index.html?path=2.50/
11-
Once you have downloaded the jar file, put it in this folder (the "integrations/selenium_grid" folder).
7+
First, download the latest selenium-server-standalone jar file to this folder (integrations/selenium_grid):
8+
```bash
9+
./download_selenium
10+
```
11+
Now you can start up the Grid Hub:
12+
```bash
13+
./grid-hub start
14+
```
15+
Now add a Grid Node to the Grid Hub:
16+
```bash
17+
./grid-node start
18+
```
19+
(NOTE: If the Grid Node is not running on the same machine as the Grid Hub, update the address from the script.)
20+
You should be able to see the Grid Console up and running from here: [http://0.0.0.0:4444/grid/console](http://0.0.0.0:4444/grid/console) (NOTE: That's the address if you're running locally from localhost.)
1221

13-
More detailed info about connecting to the Selenium Grid Hub can be found here:
14-
* https://theintern.github.io/intern/#selenium-grid
15-
and here:
16-
* https://github.com/SeleniumHQ/selenium/wiki/Grid2
17-
For even more information, look here:
18-
* https://github.com/SeleniumHQ/selenium/wiki
22+
#### More detailed info about connecting to the Selenium Grid Hub can be found here:
23+
* [https://theintern.github.io/intern/#selenium-grid](https://theintern.github.io/intern/#selenium-grid)
24+
* [https://github.com/SeleniumHQ/selenium/wiki/Grid2](https://github.com/SeleniumHQ/selenium/wiki/Grid2)
25+
* [https://github.com/SeleniumHQ/selenium/wiki](https://github.com/SeleniumHQ/selenium/wiki/Grid2)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
""" Download the selenium server jar file """
2+
3+
import os
4+
from seleniumbase.core import selenium_launcher
5+
6+
if not selenium_launcher.is_available_locally():
7+
selenium_launcher.download_selenium()
8+
9+
for filename in os.listdir("."):
10+
if filename.startswith("selenium-server-standalone-"):
11+
os.rename(filename, "selenium-server-standalone.jar")

integrations/selenium_grid/grid-hub

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/usr/bin/env bash
2+
3+
#
4+
# Usage: grid-hub {start|stop}
5+
#
6+
7+
source $(dirname $0)/util
8+
9+
EXPECTED_ARGS=1
10+
E_BADARGS=65
11+
12+
DO_showUsage() {
13+
echo "Usage: $(basename $0) {start|stop}"
14+
exit $E_BADARGS
15+
}
16+
17+
if [ $# -ne $EXPECTED_ARGS ]; then
18+
DO_showUsage
19+
fi
20+
21+
################################################################################
22+
23+
WEBDRIVER_SERVER_JAR=./selenium-server-standalone.jar
24+
WEBDRIVER_HUB_PARAMS="-role hub -port 4444"
25+
WEBDRIVER_HUB_PIDFILE="/tmp/webdriver_hub.pid"
26+
27+
if [ ! -f $WEBDRIVER_SERVER_JAR ]; then
28+
echo "You must place the Selenium-WebDriver standalone JAR file at ${WEBDRIVER_SERVER_JAR} before proceeding."
29+
exit 1
30+
fi
31+
32+
case "$1" in
33+
start)
34+
echo "Starting Selenium-WebDriver Grid2 hub..."
35+
if [ -f $WEBDRIVER_HUB_PIDFILE ]; then
36+
echo "${FAIL_MSG} Selenium-WebDriver Grid2 hub already running with PID $(cat $WEBDRIVER_HUB_PIDFILE). Run 'grid-hub stop' or 'grid-hub restart'."
37+
exit 1
38+
else
39+
START_HUB_CMD="java -Djava.util.logging.config.file=test/logging.properties -jar ${WEBDRIVER_SERVER_JAR} ${WEBDRIVER_HUB_PARAMS}"
40+
$START_HUB_CMD &
41+
PID=$!
42+
echo $PID > "${WEBDRIVER_HUB_PIDFILE}"
43+
echo "${SUCCESS_MSG} Selenium-WebDriver Grid2 hub started successfully."
44+
echo "To see full log output, remove the java.util.logging.config.file parameter from script/grid-hub"
45+
fi
46+
;;
47+
stop)
48+
echo "Stopping Selenium-WebDriver Grid2 hub..."
49+
if [ -f $WEBDRIVER_HUB_PIDFILE ]; then
50+
PID=$(cat $WEBDRIVER_HUB_PIDFILE)
51+
kill $PID
52+
rm $WEBDRIVER_HUB_PIDFILE
53+
sleep 1
54+
if [[ $(ps -A | egrep "^${PID}") ]]; then
55+
echo "${FAIL_MSG} Tried to kill the hub with PID ${PID}, but was unsuccessful. You need to kill it with something stronger, like 'kill -9'"
56+
exit 1
57+
else
58+
echo "${SUCCESS_MSG} Selenium-WebDriver Grid2 hub stopped successfully."
59+
exit 0
60+
fi
61+
else
62+
echo "${SUCCESS_MSG} Selenium-WebDriver Grid2 hub has already been stopped."
63+
exit 0
64+
fi
65+
;;
66+
restart)
67+
$0 stop
68+
$0 start
69+
;;
70+
*)
71+
DO_showUsage
72+
esac

integrations/selenium_grid/grid-node

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/usr/bin/env bash
2+
3+
#
4+
# Usage: grid-node {start|stop}
5+
#
6+
7+
source $(dirname $0)/util
8+
9+
EXPECTED_ARGS=1
10+
E_BADARGS=65
11+
12+
DO_showUsage() {
13+
echo "Usage: $(basename $0) {start|stop}"
14+
exit $E_BADARGS
15+
}
16+
17+
if [ $# -ne $EXPECTED_ARGS ]; then
18+
DO_showUsage
19+
fi
20+
21+
################################################################################
22+
23+
WEBDRIVER_SERVER_JAR=./selenium-server-standalone.jar
24+
WEBDRIVER_NODE_PARAMS="-role webdriver -hubHost 127.0.0.1 -hubPort 4444 -host 127.0.0.1 -browserName=firefox"
25+
WEBDRIVER_NODE_PIDFILE="/tmp/webdriver_node.pid"
26+
27+
if [ ! -f $WEBDRIVER_SERVER_JAR ]; then
28+
echo "You must place the Selenium-WebDriver standalone JAR file at ${WEBDRIVER_SERVER_JAR} before proceeding."
29+
exit 1
30+
fi
31+
32+
case "$1" in
33+
start)
34+
echo "Starting Selenium-WebDriver Grid2 node..."
35+
if [ -f $WEBDRIVER_NODE_PIDFILE ]; then
36+
echo "${FAIL_MSG} Selenium-WebDriver Grid2 node already running with PID $(cat $WEBDRIVER_NODE_PIDFILE). Run 'grid-node stop' or 'grid-node restart'."
37+
exit 1
38+
else
39+
START_NODE_CMD="java -Djava.util.logging.config.file=test/logging.properties -jar ${WEBDRIVER_SERVER_JAR} ${WEBDRIVER_NODE_PARAMS}"
40+
$START_NODE_CMD &
41+
PID=$!
42+
echo $PID > "${WEBDRIVER_NODE_PIDFILE}"
43+
echo "${SUCCESS_MSG} Selenium-WebDriver Grid2 node started successfully."
44+
echo "To see full log output, remove the java.util.logging.config.file parameter from script/grid-node"
45+
fi
46+
;;
47+
stop)
48+
echo "Stopping Selenium-WebDriver Grid2 node..."
49+
if [ -f $WEBDRIVER_NODE_PIDFILE ]; then
50+
PID=$(cat $WEBDRIVER_NODE_PIDFILE)
51+
kill $PID
52+
rm $WEBDRIVER_NODE_PIDFILE
53+
sleep 1
54+
if [[ $(ps -A | egrep "^${PID}") ]]; then
55+
echo "${FAIL_MSG} Tried to kill the node with PID ${PID}, but was unsuccessful. You need to kill it with something stronger, like 'kill -9'"
56+
exit 1
57+
else
58+
echo "${SUCCESS_MSG} Selenium-WebDriver Grid2 node stopped successfully."
59+
exit 0
60+
fi
61+
else
62+
echo "${SUCCESS_MSG} Selenium-WebDriver Grid2 node has already been stopped."
63+
exit 0
64+
fi
65+
;;
66+
restart)
67+
$0 stop
68+
$0 start
69+
;;
70+
*)
71+
DO_showUsage
72+
esac
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
cd c:\
2-
java -jar selenium-server-standalone-2.50.1.jar -role node -hub http://[ENTER URL OF THE GRID HUB SERVER]:4444/grid/register -browser browserName=chrome,maxInstances=5 -browser browserName=firefox,maxInstances=5 -browser browserName="internet explorer",maxInstances=1
2+
java -jar selenium-server-standalone.jar -role node -hub http://[ENTER URL OF THE GRID HUB SERVER]:4444/grid/register -browser browserName=chrome,maxInstances=5 -browser browserName=firefox,maxInstances=5 -browser browserName="internet explorer",maxInstances=1
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/bin/bash
2-
java -jar selenium-server-standalone-2.50.1.jar -role hub
2+
java -jar selenium-server-standalone.jar -role hub

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
setup(
88
name='seleniumbase',
9-
version='1.1.22',
9+
version='1.1.23',
1010
url='https://github.com/mdmintz/SeleniumBase',
1111
author='Michael Mintz',
1212
author_email='@mintzworld',

0 commit comments

Comments
 (0)