Integrate Extent Report with Screenshots inNUnit Selenium Framework (.NET Core).web admin
Setting up Visual Studio
1. Download the latest version of Visual Studio.
2. Select NUnit 3 Test project.
3. Give a project name and click next.
4. As we are creating a selenium framework, we need selenium packages and browsers driver. If you are familiar with the maven java selenium framework, in a maven project we have a pom.xml file to add the required .jar files to our project.
Similarly, we have NuGet Package Manager to add required packages to our project. We can access the NuGet Package by right click on the project.
5. Here are the packages we will need for the project.
Setting up Project Structure
For the demo I have used an online calculator to perform basic mathematical operations and verified the result from the online calculator is correct or not.
- Create folders Pages, Steps, Tests, and Utils.
- The pages folder will contain a Page class that will have the locators and unit methods.
- Steps folder will contain a Step class and we will use the object of this class to access the unit methods of the Page Class.
- Tests folder will contain the test scripts.
- Utils folder will have a helper or utility class.
Utility.cs – GetProjectRootDirectory() returns the project root directory path.
DriverUtil.cs – Initialize the correct browser driver and return the driver instance.
ExtentService.cs – Create an instance of ExtentReports if the instance is not present else it returns the instance.
ExtentTestManager.cs – Create parent test and child test which gives a hierarchy of test in extent report.
ReportLog.cs – Add logs to extent report.
BasePage.cs – Contains custom methods with the explicit wait.
HomePage.cs – Contains the locators and custom method for entering digits in the online calculator.
HomePageStep.cs – Contains the methods and each method returns the result from the online calculator.
- The OneTimeSetUp attribute is inherited from any base class. Therefore, if a base class has defined an OneTimeSetUp method, that method will be called before any methods in the derived class.
- The OneTimeTearDown attribute is inherited from any base class. Therefore, if a base class has defined an OneTimeTearDown method, that method will be called after any test methods in the derived class.
- The SetUp attribute is inherited from any base class. Therefore, if a base class has defined a SetUp method, that method will be called before each test method in the derived class.
- The TearDown attribute is inherited from any base class. Therefore, if a base class has defined a TearDown method, that method will be called after each test method in the derived class.
- The Parallelizable Attribute is used to indicate that a test and/or its descendants may be run in parallel with other tests.
Read Also:- All About Accessibility Web Testing
Test Parallel Execution – Extent Report
Counted among the best software testing company in India by Clutch and Good firms. We have an independent testing team who keeps on testing the product in all the faces of the software development life cycle.