Automating Selenium with Ant

Automating Selenium with Ant

or How to Enable Multi Browser Testing with JUnit Reports

This is a topic from the Introduction to Selenium class at LMN Solutions.
In order to pass in the browser selection from the Ant script code like this is required in your JUnit Selenium Web Driver tests. I put this code into the parent class that all my Selenium JUnit tests extend.
public static void startSelenium() throws Exception {
Properties sysProps = System.getProperties();
                String     browser = sysProps.getProperty(“”);
                if (browser == null) {
             driver = new InternetExplorerDriver();
                } else if (browser == “*firefox”) {
             driver = new FirefoxDriver();
}In the Ant build.xml file you will find the code:Which tells the JUnit code which browser to launch.You will also see:This tells JUnit to build a html report of the test results when finished.
Then I have build an Ant build.xml file that you can download. See if you can get this set up and running while I write up some step by step directions. Please send me any questions you have and make sure to check out our classes at
© Copyright 2013 LMN Solutions
If you  have a question e-mail us or add a comment.


LMN Solutions – Find out more about us.
Selenium Training
Leave Yours +

No Comments

Comments are closed.

  • Comments are Closed