Below is an example of how the test script DOS batch file is currently configured:
for /f "tokens=1-4 delims=/ " %%i in ("%date%") do set datestr=%%l%%j%%k
for /f "tokens=1-4 delims=.: " %%i in ("%time%") do set timestr=%%i%%j%%k%%l
START java -jar S:\selenium-server-standalone-2.31.0.jar -port 4445 -log S:\scripts\SVT\results\%TimeStamp%-selenium.log -browserSideLog -firefoxProfileTemplate "C:\ffprofiles\selenium" -htmlSuite "*chrome" "https://www.somedomain.org" "S:\scripts\SVT\suite-svt.html" "S:\scripts\SVT\results\%TimeStamp%-svtresults.html"
START c:\windows\DelAge32 "S:\scripts\SVT\results\*.*" 3
The first four lines setup the variables needed for creating a dynamic date value that will be used to create report folders and used in report file names (i.e., "S:\scripts\SVT\suite-svt.html" "S:\scripts\SVT\results\%TimeStamp%-svtresults.html"). Doing so allows us to not only save each version of the report file instead of over-writing it and only having the current version, but it conveniently tags the report name with the actual date so the files are easy to find and ordered in Windows by the date they were created.
Lines four and five are the most important for launching the script with the RC server. Below is a breakdown of each of the commands and parameters:
- START java -jar S:\selenium-server-standalone-2.31.0.jar: This part uses the Windows command START to start the JAVA runtime environment and pass to it the JAR file that shold be executed ... which in this case is selenium-server-standalone-2.31.0.jar. This file is downloaded from http://www.seleniumhq.org/download.
- -port 4445: This part tells the server which port to run under. What is important to note here, is that two instances cannot run under the same port number. If you want to run two instances concurrently, you will need to set one to port X, and the other to port Y.
- -log S:\scripts\SVT\results\%TimeStamp%-selenium.log -browserSideLog: This part tells the selenium server to log both server and client side actions to a time stamped log file. To force Selenium to store the log file in a location other then where the script was run from, you MUST specific the full path. Setting a relative path will cause the application to NOT launch properly when started from a Windows Scheduled Task.
- -firefoxProfileTemplate "C:\ffprofiles\selenium": This part tells the selenium server that you want to use a custom Firefox profile to launch the test (highly recommended). Instructions for setting up a custom profile can be found here: http://wtdev64-box20/book/selenium/setting-and-automation-friendly-firefox-profile
- -htmlSuite: tells the server that the test file to run will be an HTML Selenese based test, not a test in some other programming language.
- "*chrome" : This part tells the server the browser to be launched will be of the chrome kind.
- "https://www.somedomain.org": This part tells the server what the baseurl for the test to execute will be.
- "S:\scripts\SVT\suite-svt.html": This part is the actual path to the suite file to launch
- "S:\scripts\SVT\results\%TimeStamp%-svtresults.html": This part tells the server where to write the result files
The last line of the batch file uses a freeware command line utility named Delage32 (from: http://www.horstmuc.de/wbat32.htm) that makes it easy to delete any report files in the scripts results directory that are older than X number of days (as specified on the command line). A copy of this application has been attached to this page as well as an htm file with instructions on its usage. To install, just unzip the attached file, and copy the delage32.exe file to your c:\Windows directory. Then call it as per the example on the last line above.
NOTE: There must not be any spaces or special characters in the file names, or folder paths for any path used in the batch file. While the path may work when manually used with RC, it will not work when called from the Windows Scheduled Tasks command line.