Designing Test Automation Framework with Selenium

by seetaram on June 19, 2011

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.

{ 24 comments… read them below or add one }

Madhu September 20, 2011 at 12:16 pm

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

Reply

seetaram September 21, 2011 at 6:34 am

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 selftechy@gmail.com
Thanks,
Seetaram

Reply

Konda Reddy December 18, 2012 at 10:22 am

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?

Thanks&Regards
Konda Reddy.K
kondareddy2020@gmail.com

Reply

seetaram August 22, 2013 at 6:22 am

everything is there in the blog, please browse the posts…

Reply

peter sukie December 6, 2011 at 10:58 am

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

Reply

sreekumar April 5, 2012 at 11:37 am

Please give me examples/usage of TestNG Assertionts..

Reply

seetaram April 16, 2012 at 12:34 pm

TestNG Assertions are similar to JUnit… Read TestNG documentation.. Both TestNG & Junit are very much similar….

Reply

Pavan July 27, 2012 at 6:16 am

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

Reply

karthic September 12, 2012 at 11:20 am

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

Thanks in advance

Reply

Ahmed February 22, 2013 at 11:38 am

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.

Thanks,

Reply

seetaram March 7, 2013 at 6:04 am

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.

Reply

Anubhav Mishra March 26, 2013 at 10:04 am

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.

Thanks,
Anubhav

Reply

seetaram August 26, 2013 at 6:05 am

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.

Reply

Anurag Mishra July 25, 2013 at 12:33 pm

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.

Reply

Arun Bharath August 3, 2013 at 4:17 am

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 …

Reply

seetaram August 20, 2013 at 9:26 am

Learn QTP that is a very easy to use tool

Reply

Mukesh August 25, 2013 at 7:51 pm

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…..

Reply

seetaram August 26, 2013 at 4:30 am

Most of the things you asked are already there in the blog, please try to browse..

Reply

Mukesh August 25, 2013 at 7:54 pm

Explain me entire framework with some example…

Reply

seetaram August 26, 2013 at 4:29 am

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

Reply

Mukesh August 26, 2013 at 10:24 am

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 : mukesh.singh733@gmail.com

Reply

Mukesh August 26, 2013 at 10:25 am

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

Reply

Varun December 30, 2013 at 6:36 am

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

Reply

seetaram January 10, 2014 at 6:56 am

I need more details

Reply

Leave a Comment

Previous post:

Next post:

Do you want to get updates on the recent articles written? Please subscribe to RSS feed or Email