Skip to content

Commit a7f8e28

Browse files
committed
Simplify the Selenium Grid code.
1 parent 8ab15e0 commit a7f8e28

File tree

8 files changed

+51
-10
lines changed

8 files changed

+51
-10
lines changed

integrations/selenium_grid/ReadMe.md

100644100755
File mode changed.

integrations/selenium_grid/download_selenium.py

100644100755
Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,48 @@
1-
""" Download the selenium server jar file """
1+
""" Downloads the Selenium Server JAR file and renames it. """
22

33
import os
4-
from seleniumbase.core import selenium_launcher
4+
import sys
5+
import urllib
56

6-
if not selenium_launcher.is_available_locally():
7-
selenium_launcher.download_selenium()
7+
SELENIUM_JAR = ("http://selenium-release.storage.googleapis.com"
8+
"/2.53/selenium-server-standalone-2.53.0.jar")
9+
JAR_FILE = "selenium-server-standalone-2.53.0.jar"
10+
try:
11+
import selenium
12+
if selenium.__version__[0] == '3':
13+
SELENIUM_JAR = ("http://selenium-release.storage.googleapis.com"
14+
"/3.8/selenium-server-standalone-3.8.1.jar")
15+
JAR_FILE = "selenium-server-standalone-3.8.1.jar"
16+
except Exception:
17+
pass
818

9-
for filename in os.listdir("."):
10-
if filename.startswith("selenium-server-standalone-"):
11-
os.rename(filename, "selenium-server-standalone.jar")
19+
RENAMED_JAR_FILE = "selenium-server-standalone.jar"
20+
21+
22+
def download_selenium():
23+
"""
24+
Downloads the Selenium Server JAR file from its
25+
online location and stores it locally.
26+
"""
27+
try:
28+
local_file = open(JAR_FILE, 'wb')
29+
remote_file = urllib.urlopen(SELENIUM_JAR)
30+
print('Downloading Selenium Server JAR File...\n')
31+
local_file.write(remote_file.read())
32+
local_file.close()
33+
remote_file.close()
34+
print('Download Complete!\n')
35+
except Exception:
36+
raise Exception("Error downloading the Selenium Server JAR file.\n"
37+
"Details: %s" % sys.exc_info()[1])
38+
39+
40+
def is_available_locally():
41+
return os.path.isfile(RENAMED_JAR_FILE)
42+
43+
44+
if not is_available_locally():
45+
download_selenium()
46+
for filename in os.listdir("."):
47+
if filename.startswith("selenium-server-standalone-"):
48+
os.rename(filename, RENAMED_JAR_FILE)

integrations/selenium_grid/grid-node

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fi
2121
################################################################################
2222

2323
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"
24+
WEBDRIVER_NODE_PARAMS="-role webdriver -hubHost 127.0.0.1 -hubPort 4444 -host 127.0.0.1 -browser browserName=firefox,maxInstances=5,version=ANY,platform=ANY -browser browserName=chrome,maxInstances=5,version=ANY,platform=ANY"
2525
WEBDRIVER_NODE_PIDFILE="/tmp/webdriver_node.pid"
2626

2727
if [ ! -f $WEBDRIVER_SERVER_JAR ]; then
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
cd c:\
2+
java -jar selenium-server-standalone.jar -role node -hub http://localhost:4444/grid/register -browser browserName=chrome,maxInstances=5,version=ANY,platform=ANY -browser browserName=firefox,maxInstances=5,version=ANY,platform=ANY -browser browserName="internet explorer",maxInstances=1,version=ANY,platform=ANY
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
java -jar selenium-server-standalone.jar -role node -hub http://localhost:4444/grid/register -browser browserName=chrome,maxInstances=5,version=ANY,platform=ANY -browser browserName=firefox,maxInstances=5,version=ANY,platform=ANY

integrations/selenium_grid/selenium_server_config_example.cfg

100644100755
File mode changed.

integrations/selenium_grid/start-selenium-node.bat

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
cd c:\
2+
java -jar selenium-server-standalone.jar -role hub

0 commit comments

Comments
 (0)