In this tutorial, lets use Nunit framework with UI automation framework Selenium Webdriver.
- Create the project in Visual Studio and Install the Nunit framework , reference - https://www.qafeast.com/nunit/nunit_framework
- Install the Selenium webdriver framework, reference - https://www.qafeast.com/selenium-csharp/selenium_webdriver_installation1
Let's have the below folder structure to form the framework,
The Framework is a structure to write the code to achieve Reusability, Maintainance, Easy of use...
Test Folder - Test method with Nunit Annotations
Page Folder - Page objects for the web page
Util Folder - Hook.cs with setup and Teardown method
- Parse program for Excel,Json,XML,Db connection
Reports Folder - To save the output.xml file
We will take a simple example of LoginTest to navigate to https://www.qafeast.com/demo and click scrolling,
Let's have Login Page objects in LoginPage.cs in Page Folder,
Login Test in Test Folder,
Setup and Teardown method in Hook.cs folder
Open the command prompt and run the command to execute the test ,
nunit3-console ..\..\..\bin\debug\projectname.dll --where "method == login" --result=..\..\..\Reports\Output.xml
The sample code is written and pushed in Github - https://github.com/qafeast/selenium-csharp-pom