diff --git a/.gitignore b/.gitignore index f55b1c54c83..607319cef7b 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,6 @@ nosetests.xml # Developer .project .pydevproject + +# Other +selenium-server-standalone.jar diff --git a/integrations/docker/docker_setup.py b/integrations/docker/docker_setup.py index 054f3906648..63cb6309128 100755 --- a/integrations/docker/docker_setup.py +++ b/integrations/docker/docker_setup.py @@ -8,7 +8,7 @@ setup( name='seleniumbase', - version='1.1.22', + version='1.1.23', author='Michael Mintz', author_email='@mintzworld', maintainer='Michael Mintz', diff --git a/integrations/selenium_grid/ReadMe.md b/integrations/selenium_grid/ReadMe.md index 1e52aea8a6b..a3fb67c154c 100644 --- a/integrations/selenium_grid/ReadMe.md +++ b/integrations/selenium_grid/ReadMe.md @@ -4,15 +4,22 @@ The Selenium Grid Hub allows you to distribute tests to run in parallel across m ### Running the Selenium Grid Hub -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: -* http://docs.seleniumhq.org/download/ -or here: -* http://selenium-release.storage.googleapis.com/index.html?path=2.50/ -Once you have downloaded the jar file, put it in this folder (the "integrations/selenium_grid" folder). +First, download the latest selenium-server-standalone jar file to this folder (integrations/selenium_grid): +```bash +./download_selenium +``` +Now you can start up the Grid Hub: +```bash +./grid-hub start +``` +Now add a Grid Node to the Grid Hub: +```bash +./grid-node start +``` +(NOTE: If the Grid Node is not running on the same machine as the Grid Hub, update the address from the script.) +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.) -More detailed info about connecting to the Selenium Grid Hub can be found here: -* https://theintern.github.io/intern/#selenium-grid -and here: -* https://github.com/SeleniumHQ/selenium/wiki/Grid2 -For even more information, look here: -* https://github.com/SeleniumHQ/selenium/wiki +#### More detailed info about connecting to the Selenium Grid Hub can be found here: +* [https://theintern.github.io/intern/#selenium-grid](https://theintern.github.io/intern/#selenium-grid) +* [https://github.com/SeleniumHQ/selenium/wiki/Grid2](https://github.com/SeleniumHQ/selenium/wiki/Grid2) +* [https://github.com/SeleniumHQ/selenium/wiki](https://github.com/SeleniumHQ/selenium/wiki/Grid2) diff --git a/integrations/selenium_grid/download_selenium.py b/integrations/selenium_grid/download_selenium.py new file mode 100644 index 00000000000..826c255aaf0 --- /dev/null +++ b/integrations/selenium_grid/download_selenium.py @@ -0,0 +1,11 @@ +""" Download the selenium server jar file """ + +import os +from seleniumbase.core import selenium_launcher + +if not selenium_launcher.is_available_locally(): + selenium_launcher.download_selenium() + +for filename in os.listdir("."): + if filename.startswith("selenium-server-standalone-"): + os.rename(filename, "selenium-server-standalone.jar") diff --git a/integrations/selenium_grid/grid-hub b/integrations/selenium_grid/grid-hub new file mode 100755 index 00000000000..5982305de03 --- /dev/null +++ b/integrations/selenium_grid/grid-hub @@ -0,0 +1,72 @@ +#!/usr/bin/env bash + +# +# Usage: grid-hub {start|stop} +# + +source $(dirname $0)/util + +EXPECTED_ARGS=1 +E_BADARGS=65 + +DO_showUsage() { + echo "Usage: $(basename $0) {start|stop}" + exit $E_BADARGS +} + +if [ $# -ne $EXPECTED_ARGS ]; then + DO_showUsage +fi + +################################################################################ + +WEBDRIVER_SERVER_JAR=./selenium-server-standalone.jar +WEBDRIVER_HUB_PARAMS="-role hub -port 4444" +WEBDRIVER_HUB_PIDFILE="/tmp/webdriver_hub.pid" + +if [ ! -f $WEBDRIVER_SERVER_JAR ]; then + echo "You must place the Selenium-WebDriver standalone JAR file at ${WEBDRIVER_SERVER_JAR} before proceeding." + exit 1 +fi + +case "$1" in + start) + echo "Starting Selenium-WebDriver Grid2 hub..." + if [ -f $WEBDRIVER_HUB_PIDFILE ]; then + echo "${FAIL_MSG} Selenium-WebDriver Grid2 hub already running with PID $(cat $WEBDRIVER_HUB_PIDFILE). Run 'grid-hub stop' or 'grid-hub restart'." + exit 1 + else + START_HUB_CMD="java -Djava.util.logging.config.file=test/logging.properties -jar ${WEBDRIVER_SERVER_JAR} ${WEBDRIVER_HUB_PARAMS}" + $START_HUB_CMD & + PID=$! + echo $PID > "${WEBDRIVER_HUB_PIDFILE}" + echo "${SUCCESS_MSG} Selenium-WebDriver Grid2 hub started successfully." + echo "To see full log output, remove the java.util.logging.config.file parameter from script/grid-hub" + fi + ;; + stop) + echo "Stopping Selenium-WebDriver Grid2 hub..." + if [ -f $WEBDRIVER_HUB_PIDFILE ]; then + PID=$(cat $WEBDRIVER_HUB_PIDFILE) + kill $PID + rm $WEBDRIVER_HUB_PIDFILE + sleep 1 + if [[ $(ps -A | egrep "^${PID}") ]]; then + 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'" + exit 1 + else + echo "${SUCCESS_MSG} Selenium-WebDriver Grid2 hub stopped successfully." + exit 0 + fi + else + echo "${SUCCESS_MSG} Selenium-WebDriver Grid2 hub has already been stopped." + exit 0 + fi + ;; + restart) + $0 stop + $0 start + ;; + *) + DO_showUsage +esac diff --git a/integrations/selenium_grid/grid-node b/integrations/selenium_grid/grid-node new file mode 100755 index 00000000000..962a4c7723b --- /dev/null +++ b/integrations/selenium_grid/grid-node @@ -0,0 +1,72 @@ +#!/usr/bin/env bash + +# +# Usage: grid-node {start|stop} +# + +source $(dirname $0)/util + +EXPECTED_ARGS=1 +E_BADARGS=65 + +DO_showUsage() { + echo "Usage: $(basename $0) {start|stop}" + exit $E_BADARGS +} + +if [ $# -ne $EXPECTED_ARGS ]; then + DO_showUsage +fi + +################################################################################ + +WEBDRIVER_SERVER_JAR=./selenium-server-standalone.jar +WEBDRIVER_NODE_PARAMS="-role webdriver -hubHost 127.0.0.1 -hubPort 4444 -host 127.0.0.1 -browserName=firefox" +WEBDRIVER_NODE_PIDFILE="/tmp/webdriver_node.pid" + +if [ ! -f $WEBDRIVER_SERVER_JAR ]; then + echo "You must place the Selenium-WebDriver standalone JAR file at ${WEBDRIVER_SERVER_JAR} before proceeding." + exit 1 +fi + +case "$1" in + start) + echo "Starting Selenium-WebDriver Grid2 node..." + if [ -f $WEBDRIVER_NODE_PIDFILE ]; then + echo "${FAIL_MSG} Selenium-WebDriver Grid2 node already running with PID $(cat $WEBDRIVER_NODE_PIDFILE). Run 'grid-node stop' or 'grid-node restart'." + exit 1 + else + START_NODE_CMD="java -Djava.util.logging.config.file=test/logging.properties -jar ${WEBDRIVER_SERVER_JAR} ${WEBDRIVER_NODE_PARAMS}" + $START_NODE_CMD & + PID=$! + echo $PID > "${WEBDRIVER_NODE_PIDFILE}" + echo "${SUCCESS_MSG} Selenium-WebDriver Grid2 node started successfully." + echo "To see full log output, remove the java.util.logging.config.file parameter from script/grid-node" + fi + ;; + stop) + echo "Stopping Selenium-WebDriver Grid2 node..." + if [ -f $WEBDRIVER_NODE_PIDFILE ]; then + PID=$(cat $WEBDRIVER_NODE_PIDFILE) + kill $PID + rm $WEBDRIVER_NODE_PIDFILE + sleep 1 + if [[ $(ps -A | egrep "^${PID}") ]]; then + 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'" + exit 1 + else + echo "${SUCCESS_MSG} Selenium-WebDriver Grid2 node stopped successfully." + exit 0 + fi + else + echo "${SUCCESS_MSG} Selenium-WebDriver Grid2 node has already been stopped." + exit 0 + fi + ;; + restart) + $0 stop + $0 start + ;; + *) + DO_showUsage +esac diff --git a/integrations/selenium_grid/start-selenium-node.bat b/integrations/selenium_grid/start-selenium-node.bat index add08675190..e9025f0b931 100644 --- a/integrations/selenium_grid/start-selenium-node.bat +++ b/integrations/selenium_grid/start-selenium-node.bat @@ -1,2 +1,2 @@ cd c:\ -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 \ No newline at end of file +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 \ No newline at end of file diff --git a/integrations/selenium_grid/start-selenium-server.sh b/integrations/selenium_grid/start-selenium-server.sh index 5e7c614f0a4..52aad03495d 100755 --- a/integrations/selenium_grid/start-selenium-server.sh +++ b/integrations/selenium_grid/start-selenium-server.sh @@ -1,2 +1,2 @@ #!/bin/bash -java -jar selenium-server-standalone-2.50.1.jar -role hub \ No newline at end of file +java -jar selenium-server-standalone.jar -role hub \ No newline at end of file diff --git a/setup.py b/setup.py index b6e863025a1..151098296f1 100755 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name='seleniumbase', - version='1.1.22', + version='1.1.23', url='https://github.com/mdmintz/SeleniumBase', author='Michael Mintz', author_email='@mintzworld',