If a [BeforeFeature] fails, it automatically fails all the tests in that feature. I want to take a screenshot in [BeforeFeature] and attach that file to all failed tests in the feature. Unfortunately it looks like we don't have the ScenarioContext to be able to attach the screenshots.
ITakesScreenshot takesScreenshot = driver as ITakesScreenshot;
var screenshot = takesScreenshot.GetScreenshot();
string screenshotFilePath = Path.Combine(artifactDirectory, fileNameBase + "_screenshot.png");
//This next line fails because we don't have ScenarioContext while in [BeforeFeature]
var testContext = ScenarioContext.Current.ScenarioContainer.Resolve<TestContext>();
Any ideas on how to accomplish this?
Please sign in to leave a comment.