private void SaveAttachmentsToTestContext(string[] filePaths)
 {
     if (filePaths != null)
     {
         foreach (var filePath in filePaths)
         {
             LogTest.Info("Uploading file [{0}] to test context", filePath);
             try
             {
                 TestContext.AddTestAttachment(filePath);
             }
             catch
             {
                 LogTest.Error("Error uploading file [{0}] to test context", filePath);
                 throw;
             }
         }
     }
 }
        public void AfterTest()
        {
            try
            {
                DriverContext.IsTestFailed = scenarioContext.TestError != null || !driverContext.VerifyMessages.Count.Equals(0);

                try
                {
                    var filePaths = SaveTestDetailsIfTestFailed(driverContext);
                    SaveAttachmentsToTestContext(filePaths);
                }
                catch (Exception ex)
                {
                    LogTest.Error("Error saving test details");
                    LogTest.LogError(ex);
                }

                var javaScriptErrors = DriverContext.LogJavaScriptErrors();

                LogTest.LogTestEnding(driverContext);


                if (IsVerifyFailedAndClearMessages(driverContext) && scenarioContext.TestError == null)
                {
                    Assert.Fail();
                }

                if (javaScriptErrors)
                {
                    Assert.Fail("JavaScript errors found. See the logs for details");
                }
            }
            finally
            {
                DriverContext.Stop();
            }
        }