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.

3 comments:

  1. Hi.. Ramesh....
    I had one doubt in reusable methods.
    Ex: selenium.click();...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 selenium.click();method......????

    ReplyDelete
  2. 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

    ReplyDelete