public void AfterScenario(ScenarioContext scenariocontext) { //Capture screenshot after scenario try { string title = scenariocontext.ScenarioInfo.Title; string Runname = title + DateTime.Now.ToString("yyyy-MM-dd-HH_mm_ss"); string artifactDirectory = Solutionpath[0] + @"TestScreenshot\"; string screenshotFilePath = Path.Combine(Solutionpath[0] + @"TestScreenshot\", Runname + "_screenshot.png"); UtilityHelper.CaptureScreenshot(screenshotFilePath); } catch (Exception ex) { Console.WriteLine("Error while taking screenshot" + ex); } //Close session BaseTestobject.TearDown(); }