我正在尝试使用 Selenium Webdriver C# 的 Extent 报告(版本 =“3.1.3”)生成 HTML 报告,但在指定文件夹中,我无法在成功执行测试脚本后看到 HTML 文件。
如果您能帮助我找出问题所在并为此问题提供解决方案,那就太好了。
提前致谢。
请在下面找到代码片段。
namespace Selenium_Demo_01
{
[TestFixture]
public class Demo01
{
IWebDriver driver;
Program dataDriven = new Program();
public ExtentReports extent;
public ExtentTest test;
[OneTimeSetUp]
public void ClassSetup()
{
var reportPath = new ExtentHtmlReporter(@"I:\Selenium\VS Project
files\Selenium_Demo_01\
Selenium_Demo_01\Reports\Demo_Report_01.html");
extent = new ExtentReports();
extent.AttachReporter(reportPath);
}
[Test]
public void test_D365Login()
{
test = extent.CreateTest("test_D365Login");
string webTitle, webTitle1;
//Get web page Title
driver.Url = appURL;
webTitle = driver.Title;
System.Console.WriteLine(webTitle);
Assert.AreEqual(title1, webTitle);
test.Pass("Assertion passed");
//Get web page Title
webTitle1 = driver.Title;
System.Console.WriteLine(webTitle1);
Assert.AreEqual(title2, webTitle1);
test.Pass("Assertion passed");
}
[TearDown]
public void closeBrowser()
{
var status = TestContext.CurrentContext.Result.Outcome.Status;
var stacktrace = string.IsNullOrEmpty(TestContext.CurrentContext.Result.StackTrace)
? ""
: string.Format("{0}",
TestContext.CurrentContext.Result.StackTrace);
Status logstatus;
switch (status)
{
case TestStatus.Failed:
logstatus = Status.Fail;
break;
case TestStatus.Inconclusive:
logstatus = Status.Warning;
break;
case TestStatus.Skipped:
logstatus = Status.Skip;
break;
default:
logstatus = Status.Pass;
break;
}
test.Log(logstatus, "Test ended with " + logstatus + stacktrace);
extent.RemoveTest(test);
extent.Flush();
driver.Close();
}
}
范围配置.xml
<?xml version="1.0" encoding="UTF-8"?>
<extentreports>
<configuration>
<!-- report theme -->
<!-- standard, dark -->
<theme>standard</theme>
<!-- 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>Automation testing</documentTitle>
<chartVisibilityOnOpen>true</chartVisibilityOnOpen>
<!-- report name - displayed at top-nav -->
<reportName>Automation Report - Shashank R</reportName>
<!-- location of charts in the test view -->
<!-- top, bottom -->
<testViewChartLocation>bottom</testViewChartLocation>
<!-- custom javascript -->
<scripts>
<![CDATA[
$(document).ready(function() {
});
]]>
</scripts>
<!-- custom styles -->
<styles>
<![CDATA[
]]>
</styles>
</configuration>