如何从 Ant 构建运行 Selenium 2 Grid?

发布于 2024-12-02 18:31:14 字数 2056 浏览 2 评论 0原文

我正在修改我们现有的 Selenium Grid 设置,以便它可以与 Selenium 2 一起使用。设置集线器和节点的过程似乎要简单得多,但我在 Ant 构建中运行它时遇到了问题就像我以前做的那样。

我已阅读有关 Selenium 2 Grid 的 wiki 并尝试设置Ant 相应地构建。我的问题是第一个目标运行,启动集线器。然后,其他目标不会运行,但构建完成。我尝试在我自己的机器上运行这些,使用 Selenium 1 (RC) Junit 测试,并使用 TestNG 作为测试运行程序。

我的目标如下:

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

看起来 Ant 线程在第一个目标运行后就完成了。我研究了一种在新窗口中启动它们的方法,就像之前的网格一样,但除了 exec 任务之外,我没有找到其他方法。我还尝试在 exec 任务中运行集线器,并将节点作为 java 任务运行。这导致 ant 构建在 start-hub 目标之后停止执行,而不是完成。

有没有办法让我运行这个,或者有更好的方法来完成它?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

呆头 2024-12-09 18:31:14

在这里查看 Mozilla 团队的做法:

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

请注意,他们仍在使用 Grid 1 节点启动器,因为 Grid 2 在这方面是向后兼容的。但它应该让您了解如何在 ant 中处理这个问题。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文