How can I run Selenium 2 Grid from an Ant build?

*爱你&永不变心* 提交于 2019-12-14 03:05:25

问题


I'm working on modifying our existing Selenium Grid setup so that it will work with Selenium 2. The process of setting up the hub and nodes seems to be much simpler, but I'm having a problem getting it running in an Ant build the way I did before.

I've read through the wiki on Selenium 2 Grid and tried to set up the Ant build accordingly. My problem is that the first target runs, starting the hub. Then, the other targets do not run, but the build completes. I'm attempting to run these on my own machine, with Selenium 1 (RC) Junit tests, and TestNG as a test runner.

The targets I have are as follows:

<taskdef resource="testngtasks" classpath="testng-${testng.version}.jar" />

<target name="start-hub" description="Start the Selenium Grid hub">
   <java classpathref="runtime.classpath" 
      jar="${basedir}/selenium-server-standalone-${server.version}.jar" 
      fork="true"
      spawn="true">
      <arg value="-v" />
      <arg value="-role" />
      <arg value="hub" />
  </java>
</target>

<target name="start-node" 
   description="Start the Selenium Grid node"
   depends="start-hub">
   <java classpathref="runtime.classpath" 
      jar="${basedir}/selenium-server-standalone-${server.version}.jar"
      fork="true"
      spawn="true">
      <arg value="-role" />
      <arg value="rc" />
      <arg value="-hub" />
      <arg value="http://localhost:4444/grid/register" />
      <arg value="-port" />
      <arg value="5555" />
      <arg value="-browser" />
      <arg value="browserName=firefox,version=3.6,maxInstances=5,platform=WINDOWS"/>
  </java>
</target>

<target name="run-tests" description="Run the tests" depends="start-node">
   <testng classpathref="runtime.classpath"
      haltonfailure="true">
    <sysproperty key="java.security.policy" 
       file="${grid.location}/lib/testng.policy" />
    <arg value="testng.xml"/>
   </testng>
</target>

It seems like the Ant thread is finished after the first target runs. I looked at a way to start them in a new window, like the previous grid, but I didn't see a way to do that except for the exec task. I also tried running the hub in an exec task and the node as a java task. That resulted in the ant build stopping execution after the start-hub target as opposed to finishing.

Is there a way I can get this running, or is there a better way to accomplish it?


回答1:


Take a look at the way the Mozilla team does it here:

https://github.com/mozilla/moz-grid-config

Note that they're still using the Grid 1 node launchers, since Grid 2 is backwards-compatible in that respect. But it should give you an idea of how to handle this in ant.



来源:https://stackoverflow.com/questions/7264448/how-can-i-run-selenium-2-grid-from-an-ant-build

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!