Designing an automation framework – Part 2

We’ve just started with the Designing an automation framework, these articles would be little lengthy and would have some code thrown in. Understanding of c# language and Selenium test suite is expected.

Design

The design section is divided in two sections. The framework API and the Test Project.

Framework API

The framework can be designed with but not limited to below pattern.

The Framework project should have API for common widgets based on the fixed ID’s for elements, all generic and essential namespaces. Drivers for all browser integrations required. Other files essential to the functionality of the framework.

Test Project

Test project can comprise of below structure which will include scripts , reports , data files, test suites, test data files and other necessary supporting files.

Test Case Writing Format

Ideally the test case writing format must utilize below format. This has to be written in the beginning of each of  the test cases.

Format:

/*

 * Test Case Name: Test Login

 * Author: Rahul A. Dhakate

 * Created Date: 30-11-2020

 * Updated By: Charlie Jr

 * Updated Date: 01-12-2020

 * Comments:

 */

Annotations & Attributes

Below are a few attributes and their utility in current framework  – Attribute used to identify a method that is called immediately after each test is run. The method is guaranteed to be called, even if an exception is thrown.

[TestClass]

Unless this attribute is specified, the method will not be treated as a test

[OneTimeSetUp]

This attribute will execute once at startup

[Setup]

This attribute can be utilized to initialize data . Initial Data and Variable for the class can be specified here

[TearDown]

Attribute to check after the test case is executed. Can be used for cleanup and clean un-mount of the test script after it is run

Sample of a Teardown attribute
#region 
Assembly nunit.framework, Version=3.6.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb
// D:\OFFICEBOX\GIT\OBQA\Automation\Bizsense.TestAutomation\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll
#endregion

using System;

namespace NUnit.Framework
{
    
    [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
    public class TearDownAttribute : NUnitAttribute
    {
        public TearDownAttribute();
    }
}
Dhakate Rahul

Dhakate Rahul

Leave a Reply

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