Example #1
0
        public void InsertTestingSteps()
        {
            var stepName     = _scenarioContext.StepContext.StepInfo.Text;
            var featureName  = _featureContext.FeatureInfo.Title;
            var scenarioName = _scenarioContext.ScenarioInfo.Title;



            var stepType = _scenarioContext.StepContext.StepInfo.StepDefinitionType.ToString();

            if (_scenarioContext.TestError == null)
            {
                if (stepType == "Given")
                {
                    scenario.CreateNode <Given>(_scenarioContext.StepContext.StepInfo.Text).AddScreenCaptureFromPath(WebElementExtensions.CapturePassScreenshot(_driverConfig.Driver, stepName));
                }

                else if (stepType == "When")
                {
                    scenario.CreateNode <When>(_scenarioContext.StepContext.StepInfo.Text);
                }
                else if (stepType == "Then")
                {
                    scenario.CreateNode <Then>(_scenarioContext.StepContext.StepInfo.Text);
                }
                else if (stepType == "And")
                {
                    scenario.CreateNode <And>(_scenarioContext.StepContext.StepInfo.Text);
                }
            }
            else if (_scenarioContext.TestError != null)
            {
                if (stepType == "Given")
                {
                    scenario.CreateNode <Given>(_scenarioContext.StepContext.StepInfo.Text).Fail(_scenarioContext.TestError.InnerException);
                }

                else if (stepType == "When")
                {
                    scenario.CreateNode <When>(_scenarioContext.StepContext.StepInfo.Text).Fail(_scenarioContext.TestError.InnerException);
                }
                else if (stepType == "Then")
                {
                    scenario.CreateNode <Then>(_scenarioContext.StepContext.StepInfo.Text).Fail(_scenarioContext.TestError.Message).AddScreenCaptureFromPath(WebElementExtensions.CaptureFailedScreenshot(_driverConfig.Driver, stepName));
                }
            }
        }