Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/274.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
无法解析基元类型或结构:System.String钩子[AfterStep]specflow C#_C#_Selenium Webdriver_Specflow_Browser Automation_Specrun - Fatal编程技术网

无法解析基元类型或结构:System.String钩子[AfterStep]specflow C#

无法解析基元类型或结构:System.String钩子[AfterStep]specflow C#,c#,selenium-webdriver,specflow,browser-automation,specrun,C#,Selenium Webdriver,Specflow,Browser Automation,Specrun,在我的自动化中,我在运行自动化测试时遇到问题,我需要使用hook[AfterStep]输入参数的方法显示错误: 无法解析基元类型或结构:System.String BoDi.ObjectContainerException 但是在测试代码时,我意识到当我从方法中删除字符串参数时,错误就不会发生了,有人能给我一个解决这个问题的方法吗? [AfterStep] public static void InserirStepsNoRelatorio(string screenshotP

在我的自动化中,我在运行自动化测试时遇到问题,我需要使用hook[AfterStep]输入参数的方法显示错误:

无法解析基元类型或结构:System.String BoDi.ObjectContainerException

但是在测试代码时,我意识到当我从方法中删除字符串参数时,错误就不会发生了,有人能给我一个解决这个问题的方法吗?

[AfterStep]

        public static void InserirStepsNoRelatorio(string screenshotPath)
        {

            var TipoStep = ScenarioStepContext.Current.StepInfo.StepDefinitionType.ToString();


            PropertyInfo pInfo = typeof(ScenarioContext).GetProperty("ScenarioExecutionStatus", BindingFlags.Instance | BindingFlags.Public);
            MethodInfo getter = pInfo.GetGetMethod(nonPublic: true);
            object TestResult = getter.Invoke(ScenarioContext.Current, null);


            try
            {


                if (ScenarioContext.Current.TestError == null)
                {


                    if (TipoStep == "Given")
                    {

                        //objGeraScreenshot.TiraPrint(objUsaNavegador);
                        scenario.CreateNode<Given>(ScenarioStepContext.Current.StepInfo.Text).AddScreenCaptureFromPath(screenshotPath);
                    }


                    else if (TipoStep == "When")
                    {

                        scenario.CreateNode<When>(ScenarioStepContext.Current.StepInfo.Text).AddScreenCaptureFromPath(screenshotPath);

                    }

                    else if (TipoStep == "Then")
                        scenario.CreateNode<Then>(ScenarioStepContext.Current.StepInfo.Text).AddScreenCaptureFromPath(screenshotPath);
                    else if (TipoStep == "And")
                        scenario.CreateNode<And>(ScenarioStepContext.Current.StepInfo.Text).AddScreenCaptureFromPath(screenshotPath);

                }

                else if (ScenarioContext.Current.TestError != null)
                {
                    if (TipoStep == "Given")
                    {
                        var MensagemErroAtual = ScenarioContext.Current.TestError.Message;

                        scenario.CreateNode<Given>(ScenarioStepContext.Current.StepInfo.Text).Fail(MarkupHelper.CreateLabel(MensagemErroAtual, ExtentColor.Black)).AddScreenCaptureFromPath(screenshotPath);


                    }

                    else if (TipoStep == "When")
                    {
                        var MensagemErroAtual = ScenarioContext.Current.TestError.Message;

                        scenario.CreateNode<When>(ScenarioStepContext.Current.StepInfo.Text).Fail(MarkupHelper.CreateLabel(MensagemErroAtual, ExtentColor.Black)).AddScreenCaptureFromPath(screenshotPath);


                    }

                    else if (TipoStep == "Then")
                    {
                        var MensagemErroAtual = ScenarioContext.Current.TestError.Message;

                        scenario.CreateNode<Then>(ScenarioStepContext.Current.StepInfo.Text).Fail(MarkupHelper.CreateLabel(MensagemErroAtual, ExtentColor.Black)).AddScreenCaptureFromPath(screenshotPath);
                    }

                }



                //else if (ScenarioStepContext.Current.StepInfo.StepDefinitionType. != null)
                //Pending Status
                if (TestResult.ToString() == "StepDefinitionPending")
                {
                    if (TipoStep == "Given")
                        scenario.CreateNode<Given>(ScenarioStepContext.Current.StepInfo.Text).Skip(MarkupHelper.CreateLabel("Step Pendente de Desenvolvimento", ExtentColor.Blue));

                    else if (TipoStep == "When")
                        scenario.CreateNode<When>(ScenarioStepContext.Current.StepInfo.Text).Skip(MarkupHelper.CreateLabel("Step Pendente de Desenvolvimento", ExtentColor.Blue));

                    else if (TipoStep == "Then")
                        scenario.CreateNode<Then>(ScenarioStepContext.Current.StepInfo.Text).Skip(MarkupHelper.CreateLabel("Step Pendente de Desenvolvimento", ExtentColor.Blue));

                }

            }
            catch (Exception e)
            {
                Assert.Fail(e.Message);
            }

        }
[AfterStep]
公共静态void InserirStepsNoRelatorio(字符串屏幕快照路径)
{
var TipoStep=ScenarioStepContext.Current.StepInfo.StepDefinitionType.ToString();
PropertyInfo pInfo=typeof(ScenarioContext).GetProperty(“ScenarioExecutionStatus”,BindingFlags.Instance | BindingFlags.Public);
MethodInfo getter=pInfo.getMethod(非公开:true);
对象TestResult=getter.Invoke(ScenarioContext.Current,null);
尝试
{
if(ScenarioContext.Current.TestError==null)
{
如果(TipoStep==“给定”)
{
//提拉普林特(objUsaNavegador);
scenario.CreateNode(ScenarioStepContext.Current.StepInfo.Text).AddScreenCaptureFromPath(screenshotPath);
}
else if(TipoStep==“When”)
{
scenario.CreateNode(ScenarioStepContext.Current.StepInfo.Text).AddScreenCaptureFromPath(screenshotPath);
}
else if(TipoStep==“Then”)
scenario.CreateNode(ScenarioStepContext.Current.StepInfo.Text).AddScreenCaptureFromPath(screenshotPath);
else if(TipoStep==“And”)
scenario.CreateNode(ScenarioStepContext.Current.StepInfo.Text).AddScreenCaptureFromPath(screenshotPath);
}
else if(ScenarioContext.Current.TestError!=null)
{
如果(TipoStep==“给定”)
{
var mensageErrorAtual=ScenarioContext.Current.TestError.Message;
scenario.CreateNode(ScenarioStepContext.Current.StepInfo.Text).Fail(MarkupCelper.CreateLabel(MensageErrorAtual,ExtentColor.Black)).AddScreenScaptureFromPath(screenshotPath);
}
else if(TipoStep==“When”)
{
var mensageErrorAtual=ScenarioContext.Current.TestError.Message;
scenario.CreateNode(ScenarioStepContext.Current.StepInfo.Text).Fail(MarkupCelper.CreateLabel(MensageErrorAtual,ExtentColor.Black)).AddScreenScaptureFromPath(screenshotPath);
}
else if(TipoStep==“Then”)
{
var mensageErrorAtual=ScenarioContext.Current.TestError.Message;
scenario.CreateNode(ScenarioStepContext.Current.StepInfo.Text).Fail(MarkupCelper.CreateLabel(MensageErrorAtual,ExtentColor.Black)).AddScreenScaptureFromPath(screenshotPath);
}
}
//else if(ScenarioStepContext.Current.StepInfo.StepDefinitionType.!=null)
//未决状态
if(TestResult.ToString()=“StepDefinitionPending”)
{
如果(TipoStep==“给定”)
scenario.CreateNode(ScenarioStepContext.Current.StepInfo.Text).Skip(markupulper.CreateLabel(“Step Pendente de Desenvolvimento”,ExtentColor.Blue));
else if(TipoStep==“When”)
scenario.CreateNode(ScenarioStepContext.Current.StepInfo.Text).Skip(markupulper.CreateLabel(“Step Pendente de Desenvolvimento”,ExtentColor.Blue));
else if(TipoStep==“Then”)
scenario.CreateNode(ScenarioStepContext.Current.StepInfo.Text).Skip(markupulper.CreateLabel(“Step Pendente de Desenvolvimento”,ExtentColor.Blue));
}
}
捕获(例外e)
{
Assert.Fail(e.Message);
}
}
根据a,您可能无法通过传递
字符串
参数来解决此问题。您可能必须使用
属性
自定义类型

根据您可能无法通过传递
字符串
参数来解决此问题。您可能必须使用
属性
自定义类型