using AventStack.ExtentReports;
using AventStack.ExtentReports.Reporter;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Edge;
using System.Diagnostics;
using System.Threading;
using WebDriverManager;
using WebDriverManager.DriverConfigs.Impl;
namespace TestProject1
{
public class Tests
{
private IWebDriver IDriver;
ExtentHtmlReporter html;
ExtentReports extent;
ExtentTest test;
[OneTimeSetUp]
public void onetime()
{
html = new ExtentHtmlReporter(@"C:\Users\guest_at6naoe\source\repos\TestProject1\TestProject1\report.html");
html.LoadConfig(@"C:\Users\guest_at6naoe\source\repos\TestProject1\TestProject1\html-config.xml");
extent = new ExtentReports();
extent.AttachReporter(html);
}
[OneTimeTearDown]
public void onetimetd()
{
extent.Flush();
}
[SetUp]
public void SetUp()
{
IDriver = new ChromeDriver();
test=extent.CreateTest(TestContext.CurrentContext.Test.MethodName);
}
[TearDown]
public void TearDown()
{
IDriver.Quit();
}
[Test]
public void Google()
{
for (int i = 0; i < 3; i++) {
IDriver.Url = "https://www.google.com";
IDriver.FindElement(By.Name("q")).SendKeys("hi");
Thread.Sleep(4000);
var node = test.CreateNode("Node=>"+i);
node.Pass("opened google");
}
}
[Test]
public void Google2()
{
for (int i = 0; i < 3; i++)
{
IDriver.Url = "https://www.google.com";
IDriver.FindElement(By.Name("q")).SendKeys("loce");
Thread.Sleep(4000);
var node = test.CreateNode("Node=>" + i);
if (i == 2)
{
node.Fail("opened rediff");
}
else {
node.Pass("opened rediff");
}
}
}
}
}
//Config::
<?xml version="1.0" encoding="UTF-8"?>
<extentreports>
<configuration>
<!-- report theme -->
<!-- standard, dark -->
<theme>standard</theme>
<!-- enables timeline -->
<!-- defaults to true -->
<enableTimeline>true</enableTimeline>
<!-- document encoding -->
<!-- defaults to UTF-8 -->
<encoding>UTF-8</encoding>
<!-- protocol for script and stylesheets -->
<!-- defaults to https -->
<protocol>https</protocol>
<!-- title of the document -->
<documentTitle>Extent Framework</documentTitle>
<!-- report name - displayed at top-nav -->
<reportName>Build 1</reportName>
<!-- custom javascript -->
<scripts>
<![CDATA[
$(document).ready(function() {
});
]]>
</scripts>
<!-- custom styles -->
<styles>
<![CDATA[
]]>
</styles>
</configuration>
</extentreports>