How to Write a Functional Test with a Basic Test Automation Framework
This tutorial is the the next step in Creating a test automation framework with C#, Selenium 3 and Nunit; after creating the reporting module in the previous tutorial, we can finally start writing an automated functional test with the test automation framework we’ve just created.
Class 1 – Creating an Automated Test Using Selenium WebDriver 3 and C#
Class 2 – How to Create a Test Automation Framework Architecture with Selenium WebDriver 3
Class 3 – Utilizing Test Automation Framework with Advanced Capabilities
Before we begin creating a functional test, we’ll need to create a new project in the Solution, in order to have a separation between the framework’s project to the automated tests themselves.
There are two main reasons for separating the framework’s project and the tests’ project:
- Modularity of the code
- Easier to maintain a project that is dedicated to the tests
The Project will be called ‘AutomatedTestCases’. Next, change the name of the class while creating the project in Sanity.cs
It should appear as follows in the screenshot:
The automated functional tests will be executed on the blog’s page in the following url: http://blog.testproject.io
Open the file Sanity.cs and paste the following piece of code:
public class Sanity : AutomationCore
public void ClickContactUs()
Lets get into more detail about the steps of the code above:
The first step is to include the project of the automation framework into the automated tests project. This is performed by adding ‘using Test;’
Afterwards, we’ll need to inherit from the AutomationCore, in order to make the framework and browser launch before executing any tests. Next, we’ll be starting with the automated tests.
We are receiving the WebDriver from our Browser’s class and then in order to locate the element we’ll be using the FindElement method while passing the element’s Id. After we have the element we can click on it.
When the functional test is complete, the results will appear in the ‘Test Explorer’ window.
Obviously, the report we created has to appear in the path we’ve configured for it.
You have now completed the last step in designing your selenium testing framework, continue on to the Next tutorial where we’ll be covering the implementation of advanced capabilities when creating a test automation framework, and specifically: Page Object Pattern: Advantages & Implementation.
I would be happy to see your questions/ ideas / stories in the comments below!