Ecco il modo in cui stiamo correndo selenio utilizzando il driver di Firefox in modalità headless su Windows.
Creare un programma di attività di Windows, è possibile farlo utilizzando l'interfaccia utente http://windows.microsoft.com/en-US/windows/schedule-task#1TC=windows-7
o con un comando come questo:
schtasks /Create /TN Automation /TR C:\automation\automated_regression.bat /SC ONSTART /RU Administrator /RP password /F /V1
nel nostro caso, l'automazione è guidato formica, in modo che il automated_regression.bat ha qualcosa di simile
:myLoop
cd c:\automation
call ant_env.bat
call ant -f regression.xml
GOTO myLoop
dove il regression.xml ha un gli obiettivi JUnit tipici di una j selenio ava project
<property name="main.dir" location="./selweb" />
<property name="src.dir" location="${main.dir}/src" />
<property name="lib.dir" location="${main.dir}/lib" />
<property name="build.dir" location="${main.dir}/build" />
<property name="test.report" location="${main.dir}/testreport">
</property>
<path id="build.classpath">
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
</path>
<target name="clean">
<delete dir="${build.dir}" />
<delete dir="${test.report}" />
</target>
<target name="make dir" depends="clean">
<mkdir dir="${build.dir}" />
<mkdir dir="${test.report}" />
</target>
<target name="compile" depends="clean, make dir">
<javac srcdir="${src.dir}" destdir="${build.dir}" debug="true">
<classpath refid="build.classpath" />
</javac>
</target>
<target name="junit" depends="clean, make dir,compile">
<loadfile property="LATEST" srcFile="LATEST" />
<junit printsummary="no" fork="true" haltonfailure="false" dir="${main.dir}">
<classpath>
<pathelement path="${build.dir}" />
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
</classpath>
<formatter type="xml" />
<batchtest todir="${test.report}">
<fileset dir="${build.dir}">
<include name="**/tests/**/*.class" />
</fileset>
</batchtest>
</junit>
<junitreport todir="${test.report}">
<fileset dir="${test.report}">
<include name="**/*.xml"/>
</fileset>
<report format="noframes" todir="${test.report}/html" styledir="${main.dir}/style">
<param name="TITLE" expression="Selenium Test Results for build ${LATEST}"/>
</report>
<report format="frames" todir="${test.report}/html" styledir="${main.dir}/style"/>
</junitreport>
</target>
è possibile utilizzare un programma di registrazione per registrare il runtime ant ad es.
<record name="log\automation_${timestamp}.log" loglevel="verbose" append="false" />
utilizzare questo è possibile seguire ciò che sta succedendo nella vostra automazione senza testa.
The ' characters around the executable and arguments are
not part of the command.
[junit] Test com.yourtests ... FAILED
[junit] Implicitly adding C:\automation\dep\apache-ant-1.8.4\lib\ant-launcher.jar;C:\automation\dep\apache-ant-1.8.4\lib\ant.jar;C:\automation\dep\apache-ant-1.8.4\lib\ant-junit.jar;C:\automation\dep\apache-ant-1.8.4\lib\ant-junit4.jar to CLASSPATH
.....
'org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner'
'com.yourtests'
'filtertrace=true'
'haltOnError=false'
'haltOnFailure=false'
'showoutput=false'
'outputtoformatters=true'
'logfailedtests=true'
'logtestlistenerevents=false'
'formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,c:\automation\selweb\testreport\TEST-com.yourtests'
'crashfile=c:\automation\junitvmwatcher2114698975676150832.properties'
'propsfile=c:\automation\junit4190343520192991051.properties'
Abbiamo seguito questo approccio e che sta funzionando, anche i colpi dello schermo vengono prese e inserite nel rapporto del HTML formica-JUnit.
Quindi l'essenza è che è necessario eseguire il selenio tramite Windows Task Scheduler e verrà eseguito in modalità senza testa. Penso che qualcosa di simile possa essere fatto sotto linux usando il cron, ma non l'ho provato per vedere se funziona.