Skip to main content


.NET Core 2.2 Selenium Automation Framework

      This automation framework is built from the ground up as an simple to use and maintain solution. All you need to execute tests is to have .NET Core 2.2 installed. If you wish to write tests you just need to download Visual Studio 19 Community Edition.

      One of the challenges I had transitioning to the wonderful world of automation is finding really simple samples to use C# as my language of choice. Anyone in the industry knows that Java is the industry standard but I have never been one to just do what everyone else is doing. I have also seen many of my colleagues over the years get frustrated trying to learn programming fundamentals. So I needed something simple and something I could help to transition great manual testers into the automation world.

Below you will find a simple example on what a test looks like with this framework. I do not have the source code here because this is something I have over 200 hours of development time wrapped into. If you would like a demo of my framework and see the source code I have no issues doing this for you. Just reach out to me on my contact form on the main page.


From its initial design this framework was designed to do two things:


Tech Used:

Browsers Supported:

Browsers Supported in headless mode for CI/CD:


Example of a very simple test

Please beaware the below code section is NOT mobile friendly!

    
 1            using NUnit.Framework;
 2
 3            partial class SmokeTest : Core
 4            {
 5                [TestCase(TestName = "CLS-27 Normal Account Signin")] 
 6                [Order(3)]
 7                [Repeat(1)]
 8                public void NormalAccountLogin()
 9                {
10                    UseBrowser(Chrome);
11                    MaximizeBrowser();
12                    Logger(Info, "Normal Account Login Test");
13                    SetUrl = JsonCall("HomePage:Url:Homepage");
14                    ClickElement(JsonCall("HomePage:Header:LoginButton"));
15                    ShouldBe(SetUrl, JsonCall("HomePage:Url:LoginPage"));
16                    WaitForElement(JsonCall("HomePage:Loginpage:Email"));
17                    ScreenShot("After clicking Login on Homepage");
18        
19                    ClickElement(JsonCall("HomePage:Loginpage:Email"));
20                    SendKeys(JsonCall("HomePage:Loginpage:Email"), JsonCall("HomePage:Account:User"));
21                    SendKeys(JsonCall("HomePage:Loginpage:Password"), JsonCall("HomePage:Account:Password"));
22                    ScreenShot("Filled in email and password");
23        
24                    ClickElement(JsonCall("HomePage:Loginpage:LoginButton"));
25                    WaitForElement(JsonCall("HomePage:Header:MyGarage"));
26                    ScreenShot("Homepage being logged in");
27                }
28            }
    
    


What does it do?

Lines 1-3: If you notice the only thing this test needs is NUnit. Past that everything is hidden in the Core of the framework. Keeps everything very simple and clean.

Lines 5-8: The NUnit Test set up. Your Test Case Name. The order number the test will run in if you have more than one test. Finally how many times to repeat that test.

Line 10: What browser to use.

Line 11: Run the browser in full screen

Line 12: Enter in the string as an informational line into the extent report for that test.

Line 13: What URL to go to.

Line 14: Click on an element on that page that loads. In this case you can tell it is a 'LoginButton'. The text listed there is a locator string maintained in a JSON store.

Line 15: Ensure that the current URL the Selenium Webdriver is on matches to the URL we told it to go to.

Line 16: Waits for an element to appear on the screen. In this case an element called Email that is in the JSON store.

Line 17: Take a screenshot of the current Selenium controlled browser and save it into the extent reports.

Lines 19-22: We click on the Email field and then send a User Account name and its Password to the appropriate form fields. Finally we take a screenshot for the logs.

Lines 24-26: We click on the LoginButton element and then wait for the next page to load. Finally we take a screenshot to show the page as it looks with an account logged in.


I am very convinced that as you can see from the above example I could train just about any manual tester to write tests for my framework in just a couple hours. Saving them a ton of manual testing time and removing any user error from the manual process.


I should also add with this framework running in headless mode I have set this up through Jenkins to run as part of the CI/CD process. It then will send either an email, text message, or Slack message on the results of the test. This saves so much time in terms of letting Devs know immediately if some minor change broke a user flow so they can react to it. It also allows me to put my focus in further exploratory testing to catch those edge cases to the user doesn't.