public void CloseApp() { var status = TestContext.CurrentContext.Result.Outcome.Status; var stackTrace = "<pre>" + TestContext.CurrentContext.Result.StackTrace + "</pre>"; var errorMessage = TestContext.CurrentContext.Result.Message; if (status == TestStatus.Failed) { string screenShotPath = CommonFunctions.CaptureScreen(app); test.Log(Status.Fail, stackTrace + errorMessage); test.Log(Status.Fail, "Snapshot below: " + test.AddScreenCaptureFromPath(screenShotPath)); } extent.Flush(); }