Wednesday, 12 September 2012

Designing Test Automation Framework with Selenium

Designing Test Automation Framework with Selenium


Do we need to go for Test Automation? If yes, then which is the tool? If we straight away start automating test cases what are all the technical challenges we might face? Do we need a framework for Automation? How we go about designing a framework?

These are all the questions popup when we want to start Test Automation. Okay, let us start exploring answers for the above questions.

If there are hundreds of test scenarios which needs to be executed on each build then it will be a tedious task and error prone.  Because a Test Engineer might make mistakes while entering the test data and output might be wrong.  We can avoid such situations by automating the test cases.

Before selecting a tool for Test Automation, we need to analyze the technologies used for different UI components. For example, Java Swing components, Telerik controls, ExtJS tables, Ajax, Silver light, Flex / Flash controls, etc. If we want to use Selenium as Test Automation tool then the first and foremost thing needs to be checked is whether the application is a Web Application. If so, then check whether most of the UI controls are identified by the Selenium. If more than 70% of the test cases can be automated then definitely we can go ahead and automate the test cases.

In order to handle large number of test cases we need to have a clear cut strategy for designing the framework. Some of the framework functionalists can be mentioned as follows:

  1. If there is any unhandled exception, then the execution should not stop.  Particular test scenario should be stopped and continue with the next scenario.

  2. Screen shots must be taken for each error so that analyzing the failures should be easy.

  3. Proper exception handling should be done in the framework.

  4. Proper naming convention should be used

  5. Avoid hard coding test data

  6. Test Data should be parametrized using external means such as XML s, Database, Spreadsheet, etc.

  7. Logs should be created that makes life easier while analyzing the Test Execution

  8. Proper folder structure should be created.

Datadriven framework is used when there are test cases which run for multiple sets of test data. Follow the below steps to create Data Driven framework:

1. Create a folder structure inside the eclipse workspace. i.e. source files, test data, results, logs, error screenshots, etc
2. Use J Unit / TestNG to write test scripts (automated test case) or write your own Java code (run as Java application – need to have main method)
3. Parametrize the automated test cases and iterate them for all the test data sets.


  1. Hi.. Ramesh....
    I had one doubt in reusable methods.
    Ex:;...We are using this method number of times in the program can we create this method into reusable type..please tell me..if it is possiable.....can we assign this method into one variable? and in the program can we use that variable instead of;method......????

  2. Your information about Selenium scripts is really interesting. Also I want to know the latest new techniques which are implemented in selenium. Can you please update it in your website? Selenium testing training in Chennai

  3. This is excellent information. It is amazing and wonderful to visit your site.Thanks for sharng this information,this is useful to me...
    Android Training in Chennai
    Ios Training in Chennai

  4. This article is very much helpful and i hope this will be an useful information for the needed one. Keep on updating these kinds of informative things...

    Android App Development Company

  5. This article is very much helpful and i hope this will be an useful information for the needed one.Keep on updating these kinds of informative things...

    iOS App Development Company
    iOS App Development Company

  6. great and nice blog thanks sharing..I just want to say that all the information you have given here is awesome...Thank you very much for this one.
    web design Company
    web development Company
    web design Company in chennai
    web development Company in chennai
    web design Company in India
    web development Company in India

  7. Being new to the blogging world I feel like there is still so much to learn. Your tips helped to clarify a few things for me as well as giving..
    Fitness SMS
    Fitness Text
    Salon SMS
    Salon Text
    Investor Relation SMS
    Investor Relation Text

  8. it is really amazing...thanks for sharing....provide more useful information...
    Mobile app development company

  9. I wondered upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon.

    Texting API
    Text message marketing
    Digital Mobile Marketing
    Sms API
    Sms marketing

  10. Pretty article! I found some useful information in your blog, it was awesome to read, thanks for sharing this great content to my vision, keep sharing..
    PSD to Wordpress
    wordpress website development