Skip to main content

Selenium Tutorial: Ant Build for Selenium Java project

Ant is a build tool which could be used to have your tests running either from command line or from Hudson CI tool. There is detailed documentation available for ant here but probably you need to know only a little part of it for you selenium tests. The essentials which are needed to know are:
  1. Project
  2. Target (ant execution point and collection of tasks)
  3. Tasks (could be as simple as compilation)
And there would usually be following targets for Selenium tools -
  1. setClassPath - so that ant knows where you jar files are
  2. loadTestNG - so that you could use testng task in ant and use it to execute testng tests from ant
  3. init - created the build file
  4. clean - delete the build file
  5. compile - compiles the selenium tests
  6. run - executes the selenium tests
Here is my project set up for ant -
























And the ant file is -


You may also like to use mail task in your build file so that test report is emailed after test execution. You could find on mail task here

Comments

  1. Hi Tarun,

    Your selenium blog is excellent ..it helps a lot. I have a query regarding with ANT and Selenium.Do you any idea how to execute ant selenium framework on different environments. In Maven, i use profiles to build the project on diff environment. Any idea with ANT?..Plz assist me.

    ReplyDelete
  2. Looks like this answers your questions -

    http://stackoverflow.com/questions/926238/ant-equivalent-of-maven-profiles

    ReplyDelete
  3. I have configured hudson to run my test cases by invoking ant.
    But after my test cases ran successfully, build doesn't stop. I have manually stop the build. Is there a way I can fix this issue?

    ReplyDelete
  4. Not sure if there is an issue with version of ant your are using.
    I suppose you mean to say that target execution never reaches completion, right?
    Could you post your question here - http://www.seleniumtests.com/p/testing-forum.html
    with the detail of your build and the target which runs infinitely

    ReplyDelete
    Replies
    1. Hi

      your blog is very useful for the selenium beginners.

      I initially used ant to run my selenium RC and Webdriver test cases using firefox browser and worked fine. But after firefox version 11 the ant build.xml file is not at all launching the firefox browser. The same problem for chrome browser, it opens the browser but not getting the specified URL and for IE i am getting Eval method not available (issue 217)

      Do you have any suggestion?

      Delete
  5. Hi,

    Your blog was very much useful for Selenium beginners.

    Initially I used to run my selenium Webdriver and Selenium RC test cases using Ant with firefox browser ( it worked initially well)but now ( after firefox version 11)my ant build.xml file is not at all launching the firefox browser. and if at all i try some times,it fails and i had to restart my machine to run the test in eclipse atleast. The same problem with chrome it opens the browser but not pointing to the mentioned URL and with IE I am getting the error
    Eval method not found. only HtmlUnitDriver works under ant.

    do you have anyy suggestion?
    Thanks in advance.

    Arun

    ReplyDelete
    Replies
    1. Could you add more details to your question and post it here - http://www.seleniumtests.com/p/selenium-1-forum.html

      Delete
  6. Q1 How can I run selenium script using ANT on MAC?
    Q2 What all changes I need to do in build.xml file which I have created for windows but needs to run on MAC.

    ReplyDelete

Post a Comment

No spam only genuine comments :)

Popular posts from this blog

Verify email confirmation using Selenium

Note: If you are new to java and selenium then start with selenium java training videos .     Email confirmation seems to be integral part of any registration process. I came across an application which lets you provide your email address. You can follow the sign up link in you mail and then complete the registration process. Lets consider we provide GMail address for it. Now if were to use only Selenium then we would have to follow following steps - Launch GMail using Selenium; Some how search for new mail in the list of available mails; Some how click on it; Parse the mail message; Get the registration link; Follow up with registration process What do you think of an approach in which you can

Real Time JMeter Result Using Backend Listener

Since JMeter 2.13 Backend Listener has been available to create real time graph of JMeter Test. Following tutorial explain the entire process in detail. At the end of this tutorial you would be able to create JMeter Live Test Result dashboard similar to following - This tutorial borrows information from many sources and my own experiments with JMeter live reporting dashboard. I have added source of information wherever applicable But before we can build such a snazzy JMeter Live Reporting dashboard we need to understand two more components - influxDB (a time series database) and Grafana Dashboard This is a big tutorial, so take deep breath :-) and follow on. Once you complete set up specified in this tutorial then you can watch JMeter Training Video Tutorial to watch this in action. What is Time Series Database? A time series is a sequence of data points , typically consisting of successive measurements made over a time interval . Examples of time ...