Designing an automation framework – Part 1

Today more and more businesses prefer automation. Technological advances have come up to a level that AI and automation have become synonymous words. Its a need for businesses to save money and produce the best software with high quality testing standards. We are going to explore how we can create an automation framework from scratch using c# and selenium. This would be split into a few parts and here we start from Part 1. Lets go.

What would be covered

CONTENTS
Introduction
Inspired By
Naming Conventions
Design
Framework API
Test Project
Test Case Writing Format
Annotations & Attributes
[TestClass]
[OneTimeSetUp]
[Setup]
[TearDown]
nUnit Quick Primer
Important NUnit Attributes
Attribute parameters
Packages Required
Handling drivers for different browsers
Browser drivers are saved in the following location
Chrome Driver
Good To Go!
Pages
Sample Account Group List Page
Tests
Sample Test Case
Extent Reports
Test Suites
Single Login
Sample Single Login Suite
Multi Login (Or Simple Suite)
Sample Multi Login Suite
Handy Code
Element Access
Working with UI Elements
ID
XPath
Working with UI components in your tests
Messages
Text boxes
Dropdowns
Excel Login Method
Excel Data
Element Clicks
Sending Keys in Text Boxes
Report Elements
Switch To Frame
Refresh
Back Button
PDF Button
Verifying a Downloaded File
Verify Row Data
Running tests belonging to a particular property
Creating a new project
Appendix
Visual Studio Debugging Shortcuts

Introduction

There is  a need identified to write and design a new Testing Framework that will be used for writing in-house test cases using Selenium and C# language.  This new framework would allow the users to write automation scripts for web applications

C# is objected-oriented and provides all the popular features supported by OOPS namely encapsulation, polymorphism, and inheritance including others.

Selenium is an open-source test automation framework for automated cross browser testing. It supports popular web browsers – Firefox, Chrome, Microsoft Edge, Internet Explorer, Safari, etc. To interact with the underlying web browser, a collection of language specific bindings to drive the browser called Selenium WebDriver is used. 

Inspired By

This under development framework is inspired by Katalon framework. This is as far as structure of the framework is concerned. Note though, this is an independent framework write up in c#. Everything was thought up to make this framework as easy as it could be like Katalon and other selenium users in mind. That’s because it would drastically reduce their learning curve and make the framework less ambiguous for newbie’s. With that said, lets jump in.

Naming Conventions

We must follow certain naming conventions that are required as per the coding standards. Note, although generic,  these conventions  could be specific to coding language you are using.

Variables

  1. Use camel casing. E.g AccntNumber
  2. Do not remove vowels if each word in the variable name is upto 6 characters. Eg. ItemName
  3. Remove vowels if each word more than 6 characters. E.g. AccountNumber, after removal of vowels: AccntNumber.
  4. Do not remove vowel, if each word in the variable ends with it. E.g. EmployeeAccountNumber, after removal of vowels: EmplyeAccntNumber
  5. Add prefixes to variable names based on the type of the value it holds.
  6. s – String
  7. dt – Date
  8. i – Integer
  9. f – float
  10. d – double
  11. b – Boolean

E.g ItemName stores string type of data, hence, should be declared as sItemName.

Object Repository (Objects for UI controls)

In C# we use first alphabet as Caps

1. Follow same variable naming conventions from points 1 – 4 while giving name to the object.

2. Prefix object names with the reference of the controls.

  • Txt – TextBox
  • Lbl – Label
  • Ddl – DropDownList
  • Dtp – DateTimePicker
  • Chk – CheckBox
  • Rd – RadioButton
  • Btn – Button
  • Lnk – LinkButton
  • Pnl – Panel
  • Grd – Grid

E.g. TxtSaleOrderNumber, DdlItemName, BtnSave, DtpOrderDate, GrdRow, GrdColumn

We would cover the rest of the sections in upcoming parts. Stay tuned for this blog post.

Dhakate Rahul

Dhakate Rahul

Leave a Reply

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