Wednesday, December 23, 2009

How to run Selenium Grid hub and remote control through nant or command line

On the official site of Selenium Grid there is no description how to run it without ant. But download this tool just to start grid is not very convenient, so i wrote tasks for nant and found the way to run Grid from command line:

First define properties:

      <property name="selenium.server.file" value="${src.dir}\_tools\selenium\selenium-server.jar" />
<property name="selenium.grid.hub.file" value="${src.dir}\_tools\selenium\selenium-grid-hub-standalone-1.0.4.jar" />
<property name="selenium.grid.rc.file" value="${src.dir}\_tools\selenium\selenium-grid-remote-control-standalone-1.0.4.jar" />
task to start hub:
     <target name="start.selenium.grid.hub">
<exec program="java" verbose="true" failonerror="false">
<arg value="-jar" />
<arg value="${selenium.grid.hub.file}" />
</exec>
</target>
task to start remote control:
    <target name="start.selenium.grid.rc">
<exec program="java" verbose="true" failonerror="false">
<arg value="-classpath" />
<arg value="${selenium.server.file};${selenium.grid.rc.file}" />
<arg value="com.thoughtworks.selenium.grid.remotecontrol.SelfRegisteringRemoteControlLauncher" />
</exec>
</target>

Or simply from command line:

Hub:

java -jar D:\work\SeleniumDesign\build_artifacts\artifacts\continuous\source\_tools\selenium\selenium-grid-hub-standalone-1.0.4.jar

Remote Control:

java -classpath D:\work\SeleniumDesign\build_artifacts\artifacts\continuous\source\_tools\selenium\selenium-server.jar;D:\work\SeleniumDesign\build_artifacts\artifacts\continuous\source\_tools\selenium\selenium-grid-remote-control-standalone-1.0.4.jar com.thoughtworks.selenium.grid.remotecontrol.SelfRegisteringRemoteControlLauncher

Examples of build script which run selenium grid can be found here: http://code.google.com/p/design-of-selenium-tests-for-asp-net/source/browse/trunk/_build/scripts/continuous/main.build

0 comments: