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, Silverlight, 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 functionalities 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 parameterized using external means such as XMLs, Database, Spreadsheet, etc.
  7. Logs should be created that makes life easier while analyzing the Test Execution
  8. Proper folder structure should be created.


If we need to create a Test Automation Framework with all the above mentioned features (or anything beyond this) for Selenium, then we need to use the programming language as JAVA and Eclipse as the IDE (Integrated Development Environment).

Test Automation Engineers should have knowledge of Java then it makes their life easier for automating the test cases.

We will discuss further about the framework in the next blog post.

Comments 28

  • Can you explain about Datadriven framework in detail
    Thanks in advance
    Madhu Babu
    Ph: 9908005778

    • To be precise,

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

      1. Create a folder structure inside the eclipse workspace. i.e. source files, test data, results, logs, error screenshots, etc
      2. Use JUnit / 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.

      I hope this will help you. For any more clarifications, please post your questions to

      • Hi Sir,
        This is Konda Reddy and i am new to Selenium.
        I have few questions ,please reply for these questions:
        Q1:How to create log file in frame work and how to call this log file in code when ever an error occurred?
        Q2:How to create test suite for 5 tests and how to schedule them run one by one using RC and JUnit?
        Q3:How to generate the results with RC-JUnit?

        Konda Reddy.K

  • Hey there, I had aquick read of this and you have laid this out really well, you’ve aoorached this from almost a beginner level but intermmediate peeple reading this can relate and learn new things. I look forward to the next blog

  • Please give me examples/usage of TestNG Assertionts..

  • Which selenium tool is best for automating telerik objects and which language is most suitable to learn telerik objects and supported by selenium

  • Hi,
    Kindly explain me the Keyword Driven framework with example.

    Thanks in advance

  • Hi,

    I’m new to selenium and have less knowledge about Automation Frameworks. Please help me regarding this.
    1- Why we use selenium with other like TestNG, Nunit, Junite etc ?
    2- Why we do not use selenium alone.?
    3- Is TestNG, Nunit, Junit is used with Webdriver ?
    4- What should I use if I have to automate a ASP.NET project.


    • JUnit, NUnit, and TestNG are unit testing frameworks. Instead of writing a framework from the scratch they use these but still you can go ahead and write your own. Selenium is an automation tool for web applications.

  • Hi there,

    You provided general idea for designing automation framework. It would be great, if you can describe step by step instruction / codes / structure to create Framework (Keyword Driven, Data Driven and Hybrid).

    I want to learn creating automation framework in Selenium using Java Client Driver / RC Server.

    Will wait for your response.


    • That depends on your project. You should be having good hands on experience in the programming language (or scripting) and the framework structure I have explained thats enough for framework design.

  • Hi, i’m new to Selenium WebDriver.
    Can you please explain how to create Folder structure for Framework using Java. describe which folder is created for what perspective.

    thanks in Advance.

  • HI.. i have confused about selenium and Qtp.I’m interested on both,but now my query is which i sholud learn first to have a basic Automation Testing …

  • Hi sir,

    I want to know that how to create a framework. what are all the things do we need to include in framework. tell me the example with data driven and keyword driven. and also tell me how to generate report using TestNG and Junit…..

  • Explain me entire framework with some example…

    • I will try to do that but still framework development depends on the application under test.

      • Thanks sir,

        I am explaining some step , how to create framework
        1) Generic lib
        a) create common method
        b)common excel lib.

        2)Batch runner
        3)Make one excel file in insert some data
        4) Include TestNg/Junit

        i am trying this way but i am unable to report or run the entire script..

        If you have some simple way to read the data from excel sheet, write the data into it and using TestNg/ Juni to generate the final report please provide me.

        its very urgent , i have interview tomorrow so i can learn framework bcz u know how framework is important..
        my email id is :

  • Tell me step by step so i can do easily, please sir

  • Hi,

    Can we design a framework with Module+Method+Data Driven framework, without the keyword driven. Becuase, my current framework is designed without Keyword driven. In my framework, for any changes i need to modify the testng.xml or individual .xml files as part of customization is required. But, using keyword driven all is done in the excel.
    It would be highly greatful, if u help me in implementing my framework along with keyword driven framework

  • Hi,
    friends..I want to latest new realtime framework Structure.

  • Hi Sir, Could you help me by providing your suggestions on how to do proper logging in test framework. Currently I have a java based test framework but for logs I am referring to server logs. For test result details I check the testng result details on terminal. How could I maintain a better logging, please provide your suggestion , thanks alot !!

  • Hi Sitaram,

    I liked the way you have structured initial design of making automation framework. Can you also provide some sample design class or some code which can help to understand the design in realtime.

    You can email me also.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.