Skip to content

Instantly share code, notes, and snippets.

@djangofan
Last active January 3, 2016 10:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djangofan/8449305 to your computer and use it in GitHub Desktop.
Save djangofan/8449305 to your computer and use it in GitHub Desktop.
@ECHO off
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
DEL /Q chromedriver.exe
DEL /Q IEDriverServer.exe
DEL /Q selenium-server-standalone*.jar
:: This script cleans unused WebDriver temp files from your computer
ECHO Cleaning Temp\webdriver*...
for /d %%a in ( %USERPROFILE%\AppData\Local\Temp\webdriver* ) do rmdir /s /q %%a
ECHO Temp\*webdriver-profile...
for /d %%a in ( %USERPROFILE%\AppData\Local\Temp\*webdriver-profile ) do rmdir /s /q %%a
ECHO Clean script is finished. Hit any key to continue.
pause>NUL
{
"_comment" : "This is the configuration for grid hub.",
"host": ip,
"maxSessions": 11,
"port": 4444,
"cleanupCycle": 5000,
"timeout": 300000,
"newSessionWaitTimeout": -1,
"servlets": [],
"prioritizer": null,
"capabilityMatcher": "org.openqa.grid.internal.utils.DefaultCapabilityMatcher",
"throwOnCapabilityNotPresent": true,
"nodePolling": 180000,
"platform": "WINDOWS"
}
{
"_comment" : "This is configuration for the grid hub on Linux.",
"host": ip,
"maxSessions": 11,
"port": 4444,
"cleanupCycle": 5000,
"timeout": 300000,
"newSessionWaitTimeout": -1,
"servlets": [],
"prioritizer": null,
"capabilityMatcher": "org.openqa.grid.internal.utils.DefaultCapabilityMatcher",
"throwOnCapabilityNotPresent": true,
"nodePolling": 180000,
"platform": "LINUX"
}
@ECHO off
TITLE Jetty Server on 8080
ECHO Running from: %CD%
:: starts server
IF NOT DEFINED STARTDIR (
SET "STARTDIR=..\trader-runner"
)
CD %STARTDIR%
mvn.bat clean package jetty:run-war -Djbehave.webrunner.version=3.5.5
ECHO Jetty was killed. Hit any key to continue...
pause>NUL
#!/bin/sh
# starts server
start()
{
cd $MODULE
mvn jetty:run-war
}
# ----- Execute the commands -----------------------------------------
MODULE=$1
if [ "$MODULE" == "" ]; then
MODULE="../trader-runner"
fi
start $MODULE
exit 1
{
"capabilities":
[
{
"browserName": "firefox",
"acceptSslCerts": true,
"javascriptEnabled": true,
"takesScreenshot": false,
"browser-version": "26",
"platform": "WINDOWS",
"maxInstances": 3
},
{
"browserName": "chrome",
"acceptSslCerts": true,
"browser-version": "31",
"maxInstances": 3,
"platform": "WINDOWS"
},
{
"browserName": "internetExplorer",
"acceptSslCerts": true,
"maxInstances": 3,
"platform": "WINDOWS"
}
],
"configuration":
{
"_comment" : "This is configuration for the grid node 1.",
"cleanUpCycle": 2000,
"timeout": 30000,
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"port": 5555,
"host": ip,
"register": true,
"hubPort": 4444,
"maxSessions": 5
}
}
{
"capabilities":
[
{
"browserName": "firefox",
"acceptSslCerts": true,
"javascriptEnabled": true,
"takesScreenshot": false,
"firefox_profile": "",
"browser-version": "26",
"platform": "LINUX",
"maxInstances": 5
},
{
"browserName": "chrome",
"browser-version": "31",
"maxInstances": 5,
"platform": "LINUX"
}
],
"configuration":
{
"_comment" : "This is configuration for the grid node 1 on Linux.",
"cleanUpCycle": 2000,
"timeout": 30000,
"port": 5555,
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"host": ip,
"register": true,
"hubPort": 4444,
"maxSessions": 5
}
}
LINUX:
To run in IDE:
- open terminal window and run
./jetty-server.sh
- open terminal window and run
./selenium-server.sh
- run stories in IDE
WINDOWS:
To run in IDE:
- open terminal window and run
.\startWebDriverGridHub.bat
.\startWebDriverGridNode.bat
- open terminal window and run
.\jetty-server.bat
- run stories in IDE
for example: within IntelliJ-IDEA 13.0, right click on 'web-runner'
or 'web-selenium' and choose "Run 'All Tests'".
@ECHO off
SETLOCAL ENABLEDELAYEDEXPANSION
SET TITLETEXT=WebDriver Grid Hub on 4444
TITLE %TITLETEXT%
ECHO *********************************************
ECHO *
ECHO * WebDriver grid Hub instance.
ECHO *
ECHO * http://localhost:4444/grid/console
ECHO *
ECHO *********************************************
ECHO.
SET JAR=selenium-server-standalone-2.39.0.jar
SET "WGET=C:\Program Files (x86)\GnuWin32\bin\wget.exe"
IF NOT DEFINED JAVA_HOME (
ECHO You must define a JAVA_HOME environment variable before you run this script.
GOTO :ERROR
)
SET "PATH=%JAVA_HOME%\bin;%PATH%"
IF NOT EXIST "%JAR%" (
ECHO Selenium standalone server .jar is missing.
IF EXIST "%WGET%" (
"%WGET%" --dot-style=binary http://selenium.googlecode.com/files/%JAR%
TITLE %TITLETEXT%
) ELSE (
ECHO Wget.exe is missing. Install GNU Utils.
ECHO.
GOTO :ERROR
)
)
ECHO.
java.exe -jar %JAR% -role hub -hubConfig hubConfig.json -debug
IF NOT %ERRORLEVEL%==0 GOTO :ERROR
GOTO :END
:ERROR
ECHO There may have been an error. Try running the script again.
pause
:END
pause
#!/bin/bash
echo "WebDriver Grid Hub on 4444"
echo ""
echo "*********************************************"
echo "*"
echo "* WebDriver grid Hub instance."
echo "*"
echo "* http://localhost:4444/grid/console"
echo "*"
echo "*********************************************"
echo ""
jarfile=selenium-server-standalone-2.39.0.jar
wgetbin=/usr/bin/wget
if [ -z "${JAVA_HOME+xxx}" ]; then
echo JAVA_HOME is not set at all;
exit 1
fi
echo $jarfile
echo $wgetbin
echo $JAVA_HOME
export PATH="$JAVA_HOME/bin:$PATH"
echo $PATH
if [ ! -f $jarfile ]; then
echo "Jar file not found!"
if [ -f $wgetbin ]; then
echo "Wget binary is found!"
echo "Downloading Selenium standalone .jar file..."
echo ""
$wgetbin --dot-style=binary http://selenium.googlecode.com/files/$jarfile
else
echo "Wget.exe is missing."
echo ""
exit 1
fi
fi
$JAVA_HOME/bin/java -jar $jarfile -role hub -hubConfig ./hubConfig.json -debug
@ECHO off
SETLOCAL ENABLEDELAYEDEXPANSION
SET TITLETEXT=WebDriver Grid Node on 5555
TITLE %TITLETEXT%
:: Proxy for Fiddler or for BrowserMob
SET PROXY=false
SET CHROMEDRIVERZIP=chromedriver_win32.zip
SET CHROMEDRIVERVER=2.8
SET CHROMEDRIVER=chromedriver.exe
SET JAR=selenium-server-standalone-2.39.0.jar
SET IEDRIVERZIP=IEDriverServer_Win32_2.39.0.zip
SET IEDRIVER=IEDriverServer.exe
SET "WGET=C:\Program Files (x86)\GnuWin32\bin\wget.exe"
ECHO *********************************************
ECHO *
ECHO * WebDriver Grid Node
ECHO * It requires that a WebDriver JSON Hub is already running, usually on port 4444 .
ECHO * You can run more than one of these if each has its own JSON config file.
ECHO *
ECHO *********************************************
ECHO.
IF NOT DEFINED JAVA_HOME (
ECHO You must define a JAVA_HOME environment variable before you run this script.
GOTO :ERROR
)
SET "PATH=.;%JAVA_HOME%\bin;%PATH%"
IF NOT EXIST "%JAR%" (
IF EXIST "%WGET%" (
"%WGET%" --dot-style=binary http://selenium.googlecode.com/files/%JAR%
) ELSE (
ECHO Wget.exe is missing. Install GNU utils. & GOTO :ERROR
)
)
IF NOT EXIST "%IEDRIVER%" (
IF EXIST "%WGET%" (
"%WGET%" --dot-style=binary http://selenium.googlecode.com/files/%IEDRIVERZIP%
jar.exe xvf %IEDRIVERZIP%
DEL /Q %IEDRIVERZIP%
) ELSE (
ECHO Wget.exe is missing. & GOTO :ERROR
)
)
IF NOT EXIST "%CHROMEDRIVER%" (
IF EXIST "%WGET%" (
"%WGET%" --dot-style=binary --no-check-certificate http://chromedriver.storage.googleapis.com/%CHROMEDRIVERVER%/%CHROMEDRIVERZIP%
jar.exe xvf %CHROMEDRIVERZIP%
DEL /Q %CHROMEDRIVERZIP%
) ELSE (
ECHO Wget.exe is missing. & GOTO :ERROR
)
)
ECHO.
ECHO ======================
ECHO Grid Hub status : & netstat -an | FIND "4444"
IF NOT %ERRORLEVEL%==0 (
ECHO Hub is required to run first.
:: You can disable this check if you need to run a Node on a different computer.
ECHO.
GOTO :ERROR
)
ECHO ======================
ECHO.
:: Set JAVA_OPTS java options to JVM
SET "JAVA_OPTS=-Dwebdriver.chrome.driver=%CD%\%CHROMEDRIVER%"
IF "%PROXY%"=="true" SET "JAVA_OPTS=%JAVA_OPTS% -DproxySet=true -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=8888"
TITLE %TITLETEXT%
java.exe -jar %JAR% -role node -nodeConfig node1Config.json %JAVA_OPTS%
GOTO :END
:ERROR
pause
:END
#!/bin/bash
echo "WebDriver Grid Hub on 4444"
echo ""
echo "*********************************************"
echo "*"
echo "* WebDriver Grid Node"
echo "* It requires that a WebDriver JSON Hub is already running, usually on port 5555."
echo "* You can run more than one of these if each has its own JSON config file."
echo "*"
echo "*********************************************"
echo ""
chromever=2.8
chromedriverzip=chromedriver_linux64.zip
chromedriverbin=chromedriver
jarfile=selenium-server-standalone-2.39.0.jar
wgetbin=/usr/bin/wget
if [ -z "${JAVA_HOME+xxx}" ]; then
echo JAVA_HOME is not set at all;
exit 1
fi
echo JARFILE=$jarfile
echo WGET=$wgetbin
echo JAVA_HOME=$JAVA_HOME
export PATH="$JAVA_HOME/bin:$PATH"
echo PATH=$PATH
if [ ! -f $jarfile ]; then
echo "Jar file not found!"
if [ -f $wgetbin ]; then
echo "Wget binary is found!"
echo "Downloading Selenium standalone .jar file..."
echo ""
$wgetbin --dot-style=binary http://selenium.googlecode.com/files/$jarfile
else
echo "Wget.exe is missing."
echo ""
exit 1
fi
fi
if [ ! -f $chromedriverbin ]; then
if [ ! -f $chromedriverzip ]; then
echo "Downloading Selenium chromedriver file..."
echo ""
$wgetbin --dot-style=binary --no-check-certificate http://chromedriver.storage.googleapis.com/$chromever/$chromedriverzip
else
echo "Chrome driver was found in current directory."
echo ""
fi
$JAVA_HOME/bin/jar xvf $chromedriverzip
rm -rf $chromedriverzip
fi
$JAVA_HOME/bin/java -jar $jarfile -role node -nodeConfig node1ConfigLinux.json -Dwebdriver.chrome.driver=$chromedriverbin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment