Skip to content

Commit dae7c8b

Browse files
committed
Update and refactor Selenium Grid code
1 parent 719ed7c commit dae7c8b

File tree

5 files changed

+10
-22
lines changed

5 files changed

+10
-22
lines changed

seleniumbase/utilities/selenium_grid/grid-hub

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ case "$1" in
5252
echo ""
5353
exit 1
5454
else
55-
# START_HUB_CMD="java -Djava.util.logging.config.file=test/logging.properties -jar ${WEBDRIVER_SERVER_JAR} ${WEBDRIVER_HUB_PARAMS}"
5655
START_HUB_CMD="java ${VERBOSITY_STRING}-jar ${WEBDRIVER_SERVER_JAR} ${WEBDRIVER_HUB_PARAMS}"
5756
echo ""
5857
echo $START_HUB_CMD
@@ -71,8 +70,8 @@ case "$1" in
7170
echo "Stopping Selenium-WebDriver Grid Hub..."
7271
if [ -f $WEBDRIVER_HUB_PIDFILE ]; then
7372
PID=$(cat $WEBDRIVER_HUB_PIDFILE)
74-
kill $PID
7573
rm $WEBDRIVER_HUB_PIDFILE
74+
kill $PID
7675
sleep 1
7776
if [[ $(ps -A | egrep "^${PID}") ]]; then
7877
echo "${FAIL_MSG} Tried to kill the Grid Hub with PID ${PID}, but was unsuccessful. You need to kill it with something stronger, like 'kill -9'"

seleniumbase/utilities/selenium_grid/grid-node

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ if [ "$GRID_NODE_VERBOSE_LOGS" == "True" ]; then
4040
fi
4141

4242
WEBDRIVER_SERVER_JAR=${DIR}/selenium-server-standalone.jar
43-
# WEBDRIVER_NODE_PARAMS="-role node -hubHost ${GRID_HUB_SERVER_IP} -hubPort 4444 -host 127.0.0.1 -browser browserName=chrome,maxInstances=5,version=ANY,platform=ANY -browser browserName=firefox,maxInstances=5,version=ANY,platform=ANY -browser browserName=MicrosoftEdge,maxInstances=1,version=ANY,platform=WIN10"
44-
WEBDRIVER_NODE_PARAMS="-role node -hub http://${GRID_HUB_SERVER_IP}:4444/grid/register -browser browserName=chrome,maxInstances=5,version=ANY,seleniumProtocol=WebDriver -browser browserName=firefox,maxInstances=5,version=ANY,seleniumProtocol=WebDriver -browser browserName=MicrosoftEdge,maxInstances=1,version=ANY,platform=WIN10,seleniumProtocol=WebDriver"
43+
WEBDRIVER_NODE_PARAMS="-role node -hub http://${GRID_HUB_SERVER_IP}:4444/grid/register -browser browserName=chrome,maxInstances=5,version=latest,seleniumProtocol=WebDriver -browser browserName=firefox,maxInstances=5,version=latest,seleniumProtocol=WebDriver"
4544
WEBDRIVER_NODE_PIDFILE="/tmp/webdriver_node.pid"
4645

4746
if [ ! -f $WEBDRIVER_SERVER_JAR ]; then
@@ -56,7 +55,6 @@ case "$1" in
5655
echo "${FAIL_MSG} Selenium-WebDriver Grid node already running with PID $(cat $WEBDRIVER_NODE_PIDFILE). Run 'grid-node stop' or 'grid-node restart'."
5756
exit 1
5857
else
59-
# START_NODE_CMD="java -Djava.util.logging.config.file=test/logging.properties -jar ${WEBDRIVER_SERVER_JAR} ${WEBDRIVER_NODE_PARAMS}"
6058
START_NODE_CMD="java ${VERBOSITY_STRING}-jar ${WEBDRIVER_SERVER_JAR} ${WEBDRIVER_NODE_PARAMS}"
6159
echo ""
6260
echo $START_NODE_CMD
@@ -66,17 +64,15 @@ case "$1" in
6664
echo $PID > "${WEBDRIVER_NODE_PIDFILE}"
6765
echo "${SUCCESS_MSG} Selenium-WebDriver Grid node started successfully."
6866
echo ""
69-
echo "Browser Sessions: http://127.0.0.1:5555/wd/hub/static/resource/hub.html"
70-
echo ""
7167
# echo "To see full log output, remove the java.util.logging.config.file parameter from script/grid-node"
7268
fi
7369
;;
7470
stop)
7571
echo "Stopping Selenium-WebDriver Grid node..."
7672
if [ -f $WEBDRIVER_NODE_PIDFILE ]; then
7773
PID=$(cat $WEBDRIVER_NODE_PIDFILE)
78-
kill $PID
7974
rm $WEBDRIVER_NODE_PIDFILE
75+
kill $PID
8076
sleep 1
8177
if [[ $(ps -A | egrep "^${PID}") ]]; then
8278
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'"

seleniumbase/utilities/selenium_grid/grid_node.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -115,23 +115,16 @@ def main():
115115
else:
116116
if grid_hub_command == "start" or grid_hub_command == "restart":
117117
shell_command = (
118-
"""java -jar %s/selenium-server-standalone.jar -role node """
119-
"""-hub http://%s:4444/grid/register -browser browser"""
120-
"""Name=chrome,maxInstances=5,version=ANY,seleniumProtocol="""
121-
"""WebDriver -browser browserName=firefox,maxInstances=5,"""
122-
"""version=ANY,seleniumProtocol=WebDriver -browser browser"""
123-
"""Name=MicrosoftEdge,maxInstances=1,version=ANY,"""
124-
"""platform=WIN10,seleniumProtocol=WebDriver"""
118+
"""java -jar %s/selenium-server-standalone.jar -role node"""
119+
""" -hub http://%s:4444/grid/register -browser browser"""
120+
"""Name=chrome,maxInstances=5,version=latest,"""
121+
"""seleniumProtocol=WebDriver -browser browserName=firefox,"""
122+
"""maxInstances=5,version=latest,seleniumProtocol=WebDriver"""
125123
% (dir_path, server_ip)
126124
)
127125
print("\nStarting Selenium-WebDriver Grid node...\n")
128126
print(shell_command)
129127
print("")
130-
print(
131-
"""Browser Sessions: http://127.0.0.1:5555"""
132-
"""/wd/hub/static/resource/hub.html"""
133-
)
134-
print("")
135128
subprocess.check_call(shell_command, shell=True)
136129
elif grid_hub_command == "stop":
137130
print("")
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
java -jar selenium-server-standalone.jar -role node -hub http://127.0.0.1:4444/grid/register -browser browserName=chrome,maxInstances=5,version=ANY,seleniumProtocol=WebDriver -browser browserName=firefox,maxInstances=5,version=ANY,seleniumProtocol=WebDriver -browser browserName=MicrosoftEdge,maxInstances=1,version=ANY,platform=WIN10,seleniumProtocol=WebDriver
1+
java -jar selenium-server-standalone.jar -role node -hub http://127.0.0.1:4444/grid/register -browser browserName=chrome,maxInstances=5,version=latest,seleniumProtocol=WebDriver -browser browserName=firefox,maxInstances=5,version=latest,seleniumProtocol=WebDriver
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.jar -role node -hub http://127.0.0.1:4444/grid/register -browser browserName=chrome,maxInstances=5,version=ANY,seleniumProtocol=WebDriver -browser browserName=firefox,maxInstances=5,version=ANY,seleniumProtocol=WebDriver -browser browserName=MicrosoftEdge,maxInstances=1,version=ANY,platform=WIN10,seleniumProtocol=WebDriver
2+
java -jar selenium-server-standalone.jar -role node -hub http://127.0.0.1:4444/grid/register -browser browserName=chrome,maxInstances=5,version=latest,seleniumProtocol=WebDriver -browser browserName=firefox,maxInstances=5,version=latest,seleniumProtocol=WebDriver

0 commit comments

Comments
 (0)