Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 无法使用c在selenium中生成扩展数据块报告(版本3.1.3)#_C#_Selenium_Selenium Webdriver_C# 3.0_Selenium Extent Report - Fatal编程技术网

C# 无法使用c在selenium中生成扩展数据块报告(版本3.1.3)#

C# 无法使用c在selenium中生成扩展数据块报告(版本3.1.3)#,c#,selenium,selenium-webdriver,c#-3.0,selenium-extent-report,C#,Selenium,Selenium Webdriver,C# 3.0,Selenium Extent Report,我是C#新手,我正在尝试使用ExtentReports生成报告(使用的版本:3.13)。在此方面的任何帮助都将不胜感激,谢谢 我得到以下错误: 消息:System.InvalidOperationException:未启动任何报告程序。必须至少启动1个reporter才能创建测试 这是我的密码:` 使用AventStack.ExtentReports; 使用AventStack.ExtentReports.Reporter; 使用NUnit.Framework; 使用NUnit.Framewo

我是C#新手,我正在尝试使用ExtentReports生成报告(使用的版本:3.13)。在此方面的任何帮助都将不胜感激,谢谢

我得到以下错误: 消息:System.InvalidOperationException:未启动任何报告程序。必须至少启动1个reporter才能创建测试

这是我的密码:`

使用AventStack.ExtentReports;
使用AventStack.ExtentReports.Reporter;
使用NUnit.Framework;
使用NUnit.Framework.Interfaces;
使用制度;
使用System.Collections.Generic;
使用System.Linq;
使用系统文本;
使用System.Threading.Tasks;
命名空间自动报告
{
类报告生成类
{
受保护的扩展端口\u范围;
保护延伸试验;
[一次性设置]
受保护的无效设置()
{
var dir=TestContext.CurrentContext.TestDirectory+“\\”;
var fileName=this.GetType().ToString()+“.html”;
var htmlReporter=新的ExtentHtmlReporter(dir+fileName);
_区段=新的扩展端口();
_extent.AttachReporter(htmlReporter);
}
[onetimeeartown]
受保护的void拆卸()
{
_expndure.Flush();
}
[设置]
测试前公共无效()
{
_test=_extent.CreateTest(TestContext.CurrentContext.test.Name);
}
[撕裂]
公开无效后验()
{
var status=TestContext.CurrentContext.Result.output.status;
var stacktrace=string.IsNullOrEmpty(TestContext.CurrentContext.Result.stacktrace)
? ""
:string.Format(“{0}”,TestContext.CurrentContext.Result.StackTrace);
状态日志状态;
开关(状态)
{
案例测试状态。失败:
logstatus=状态。失败;
打破
案例测试状态。非决定性:
logstatus=状态。警告;
打破
案例测试状态。已跳过:
logstatus=Status.Skip;
打破
违约:
logstatus=状态。通过;
打破
}
_测试日志(logstatus,“测试以“+logstatus+stacktrace”结束);
_expndure.Flush();
}
[测试]
public void PassingTest()
{
ExtentReports区段=新的ExtentReports();
_test=extent.CreateTest(“PassingTest”);
Driver.Navigate().gotour(“http://www.google.com");
尝试
{
Assert.IsTrue(真);
_测试通过(“断言通过”);
_测试日志(Status.Pass,“Pass”);
}
捕获(断言异常)
{
_测试失败(“断言失败”);
_测试日志(Status.Fail,“Fail”);
投掷;
}
}
}

}
PassingTest
方法中,删除以下行:

ExtentReports extent = new ExtentReports();
_test = extent.CreateTest("PassingTest");
它应该会起作用


您已经在
[OneTimeSetUp]
[SetUp]
方法中正确初始化了
ExtentReports
对象和
\u test
字段,但是您在测试方法中重复错误地覆盖了它。

谢谢Arnon Axelrod。欢迎!如果它解决了你的问题,如果你把我的答案标记为接受,那就太好了。谢谢