2013-06-12 6 views
15

Firefoxのドライバを使用するようにSeleniumを設定し、Windowsでブラウザを無人で実行できますか?Windows版ヘッドレスFirefoxブラウザをご利用の場合

私はWindowsやLinuxでは動作していますが、上記の特別なケースでは動作しない他のドライバについて知ります。読めるようにするための参照情報(それを達成するための特別な方法、制限など)は非常に簡素化されています。ここで

よろしく、

答えて

2

私たちは窓の上にヘッドレスモードでFirefoxのドライバを使用してセレンを実行している方法です。

は、Windowsのタスクのスケジュールを作成し、あなたはUI http://windows.microsoft.com/en-US/windows/schedule-task#1TC=windows-7

または、このようなコマンドで使用してこれを行うことができ、次のいずれか私たちのケースで

schtasks /Create /TN Automation /TR C:\automation\automated_regression.bat /SC ONSTART /RU Administrator /RP password /F /V1 

を、自動化が駆動アリなので、 automated_regression.batはregression.xmlはセレンjの典型的なJUnitの目標を持って、この

:myLoop 
cd c:\automation 
call ant_env.bat 
call ant -f regression.xml 
GOTO myLoop 

のようなものを持っていますAVAプロジェクト

<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> 

はあなたのアリランタイムなどを記録するロガーを使用することができます。

<record name="log\automation_${timestamp}.log" loglevel="verbose" append="false" /> 

これを使用すると、ヘッドレスの自動化で何が起こっているのかを知ることができます。

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' 

私たちは、このアプローチを踏襲しており、それが働いて、でも、スクリーンショットは、アリのJUnit HTMLレポートで撮影して挿入されています。

したがって、Windows Tasks Schedulerを使用してセレンを実行する必要があり、ヘッドレスモードで実行する必要があります。私はLinuxでcronを使って同様のことをすることができると思いますが、動作しているかどうか試してみませんでした。

10

OSのWindowsでサポートされている専用の仮想デスクトップを介してブラウザ(Firefox、IEなど)を実行することは可能です。そのタスクのためのそのような既知のヘルパーユーティリティの1つはHeadless Selenium for Windowsです。

関連する問題