Created
March 3, 2014 14:46
-
-
Save thecodeite/9326495 to your computer and use it in GitHub Desktop.
Script to setup Selenium as server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
set SERVER_VERSION=2.40.0 | |
:REM This will update the Selenium Server Windows Service with the most recent Version | |
:REM of Selenium Server. | |
:REM | |
:REM Prerequisits: | |
:REM * Download Selenium Server to Downloads Folder | |
:REM * Download IE-Server to Downloads Folder and Unzip to Downloads Folder (using suggested name) | |
set DOWNLOADS_FOLDER=%HOMEPATH%\Downloads | |
set SERVICE_NAME=Selenium Server | |
:REM http://nssm.cc/ | |
set NSSM=%systemRoot%\nssm.exe | |
set JAVA=%ProgramFiles%\Java\jre7\bin\java.exe | |
set SERVER_BASENAME=selenium-server-standalone | |
set IESERVER_BASENAME=IEDriverServer_Win32 | |
set SERVER_JAR=%DOWNLOADS_FOLDER%\%SERVER_BASENAME%-%SERVER_VERSION%.jar | |
set SHROMESERVER_EXEC=%DOWNLOADS_FOLDER%\ChromeDriver.exe | |
if not exist "%NSSM%" ( | |
echo. | |
echo Could not find "%NSSM%! | |
echo. | |
echo Please download at http://nssm.cc/ | |
echo. | |
pause | |
exit /B 1 | |
) | |
if not exist "%JAVA%" ( | |
echo. | |
echo Could not find "%JAVA%! | |
echo. | |
echo Please download at http://www.java.com/en/download/ | |
echo. | |
pause | |
exit /B 1 | |
) | |
if not exist "%SERVER_JAR%" ( | |
echo. | |
echo Could not find "%SERVER_JAR%"! | |
echo. | |
echo Please download from http://docs.seleniumhq.org/download/ | |
echo. | |
pause | |
exit /B 1 | |
) | |
if not exist "%SHROMESERVER_EXEC%" ( | |
echo. | |
echo Could not find "%SHROMESERVER_EXEC%"! | |
echo. | |
echo Please download from http://docs.seleniumhq.org/download/ | |
echo and unzip to %DOWNLOADS_FOLDER% | |
echo. | |
pause | |
exit /B 1 | |
) | |
echo [SC] Stopping service "%SERVICE_NAME%" | |
sc stop "%SERVICE_NAME%" >NUL 2>NUL | |
echo [NSSM] Trying to remove possibly pre-existing service "%SERVICE_NAME%"... | |
"%NSSM%" remove "%SERVICE_NAME%" confirm > NUL 2>NUL | |
echo [NSSM] Installing as Service: | |
echo * Selenium Server: Version %SERVER_VERSION% | |
echo. | |
echo Path: "%SERVER_JAR%" | |
echo. | |
echo * Schrome Server: | |
echo. | |
echo Path: "%SHROMESERVER_EXEC%" | |
echo. | |
"%NSSM%" install "%SERVICE_NAME%" "%JAVA%" -jar ""%SERVER_JAR%"" -Dwebdriver.chrome.driver=""%SHROMESERVER_EXEC%"" -timeout 120 -browserTimeout 120 | |
if not errorlevel 1 ( | |
echo. | |
echo [SC] Configuring Service to allow access to desktop | |
echo. | |
sc config "%SERVICE_NAME%" type= own type= interact | |
echo. | |
echo [SC] Starting Selenium Server | |
echo. | |
sc start "%SERVICE_NAME%" | |
) | |
echo. | |
echo Selenium Server should be available at: | |
echo http://%COMPUTERNAME%:4444/wd/hub | |
echo. | |
echo If you cannot reach the selenium server please check the firewall settings | |
echo on this machine. | |
echo. | |
echo Close if you are done reading... | |
pause | |
exit /b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment