Home > Selenium, Selenium Grid > How to stop selenium Grid from Ant build?

How to stop selenium Grid from Ant build?

How to stop selenium Grid from Ant build?

This is also a very simple process as similar to starting the Selenium Grrid from a bat/sh file[mentioned here].

First of all we need to create a bat/file with either of following commands

curl -d action=shutdown http://localhost:4444/lifecycle-manager

wget --post-data action=shutdown action=shutdown http://localhost:4444/lifecycle-manager

Save the bat file in the Selenium Grid base directory. Double check bat file whether its working fine by double clicking on that[pre condition : Selenium Hub and RCs must started before].

I am using this way because there is no default ant target for shutting down the Selenium Grid.

Coming to Ant Build, we need to create a custom ant target in build.xml to execute the above bat file. It look like

<target name=”stopGrid”>
<exec dir=”${grid.dir}” executable=”cmd” os=”Windows XP”>
<arg line=”/c stopGrid.bat”/>

Save the build.xml and execute target as ‘ant stopGrid‘.

Happy testing…

  1. June 15, 2011 at 9:11 pm

    Couldn’t you also do something like this ?

    • anoopvdk
      June 15, 2011 at 9:52 pm

      Hi SirGeek,
      I could not able to see your comment. I think its due to html tags. Could you please try again with using textarea tag.

  2. June 15, 2011 at 10:26 pm

    Sure, Try #2:

  3. June 15, 2011 at 10:27 pm

    Try #3

  4. June 15, 2011 at 10:28 pm

    Try #4

    <target name=”stop.selenium.grid”>
    <echo taskname=”stop.selenium.grid” message=”Stopping servers.” />
    <!– Shutdown Selenium. –>
    <get taskname=”stop.selenium” src=”http://localhost:4444/lifecycle-manager?action=shutdown” dest=”${logs}/shutdown_results.txt” ignoreerrors=”true” />

    • anoopvdk
      June 20, 2011 at 10:49 pm

      Yes, we can do. In both cases, we are trying to shutdown selenium server by passing parameters through URL.

    • Test
      October 18, 2011 at 4:58 pm

      Not able to get the grid stopped by using this target.. any suggestions plz.

  5. Rakesh Singh
    January 31, 2012 at 4:18 pm

    This doesn’t holds true with selenium 2. user cannot stop selenium hub /agent in selenium 2

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: