I am creating selenium C# frameworke and added Extent Report in it. I have two classes when I run my code my first-class test report gets overwritten by the second class Test report. How can I generate multiple class extent reports in a single report. I know my test variable of ExtentTest is getting over-written when a new class gets execute but I do not know how to fix it. I know in Java we can use ITestReport but in C# no function like that is working.
My Base Class:
{
public IWebDriver driver;
public static ExtentReports extent;
public static ExtentTest test ;
public static ExtentHtmlReporter htmlReporter;
[OneTimeSetUp]
public void ExtendStart()
{
extent = new ExtentReports();
htmlReporter = new ExtentHtmlReporter("D:\\TitleHoundEndToEndTesting\\TitleHoundEndToEndTesting\\ExtentReports\\Current-SeleniumRepprt.html");
extent.AttachReporter(htmlReporter);
}
[SetUp]
public void startBrowser()
{
driver = new ChromeDriver("D:\\");
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30);
}
public MediaEntityModelProvider CaptureScreenShot()
{
var screenshot = ((ITakesScreenshot)driver).GetScreenshot().AsBase64EncodedString;
return MediaEntityBuilder.CreateScreenCaptureFromBase64String(screenshot).Build();
}
[TearDown]
public void closeBrowser()
{
driver.Close();
}```
**My Login Class**
``` [Test]
public void BLoginTest()
{
try
{
test = extent.CreateTest("Login Test Is Getting Exectuted");
driver.Url = "https://test.line.com/";
driver.Manage().Window.Maximize();
var login = new Login(driver);
login.LoginMethod();
test.Log(Status.Pass, "Login Test Method is Passed");
}
catch (Exception e)
{
if (attempts <= 3)
{
attempts++;
Thread.Sleep(8000);
BLoginTest();
}
else
{
var ss = CaptureScreenShot();
test.Log(Status.Fail, "Login Test Method is Failed" + e, ss);
Assert.Fail();
}
}
}```
**My NewQuote Class**
``` [Test]
public void ANewQuoteTest()
{
try
{
test = extent.CreateTest("NewQuote Test Is Getting Exectuted");
driver.Url = "https://test.titlehoundonline.com/";
driver.Manage().Window.Maximize();
var newqoute = new NewQuote(driver);
newqoute.GetQouteMethod();
test.Log(Status.Pass, "Login Test Method is Passed");
}
catch(Exception e)
{
if (attempts <= 3)
{
attempts++;
Thread.Sleep(8000);
ANewQuoteTest();
}
else
{
var ss = CaptureScreenShot();
test.Log(Status.Fail, "LogOutTest Test Method is Failed" + e, ss);
Assert.Fail();
}
}
}```