分享:在ant的build文件中启动以及关闭selenium rc sever
在ant的build文件中启动以及关闭selenium rc sever通过ant运行selenium的脚本时,每次手动启动selenium server很麻烦。将如下的代码加入ant的build.xml,可以实现每次运行build.xml时,系统会自动启动selenium rc server和关闭selenium rc server.
如果你的firefox运行不需要设置代理:
<target name="start_RC_server" description="Starts a Selenium Server in the background">
<java jar="./seleniumRc/selenium-server-standalone-2.39.0.jar" fork="true" spawn="true" />
<waitfor maxwait="3" maxwaitunit="second">
<socket server="localhost" port="4444"/>
</waitfor>
如果你的firefox运行需要设置代理:
<java jar="./seleniumRc/selenium-server-standalone-2.39.0.jar" fork="true" spawn="true" >
<arg line="-firefoxProfileTemplate${basedir}/Proxy_SP/" />
</java>
<waitfor maxwait="3" maxwaitunit="second">
<socket server="localhost" port="4444"/>
</waitfor>
</target> ant的build.xml文件中关闭selenium rc server的代码:
<target name="stop_rc_server" depends="transform"description="Stops your local Selenium Server">
<get taskname="selenium-shutdown"
src="http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer"
dest="result.txt"
ignoreerrors="true" />
</target>
页:
[1]