public virtual void TestCleanUp() { var testResult = TestContext.CurrentTestOutcome; bool isTestFailed = !(testResult == UnitTestOutcome.Passed || testResult == UnitTestOutcome.Inconclusive); if (isTestFailed) { try { var myUniqueFileName = string.Format(@"screenshot_{0}.png", Guid.NewGuid()); var fullPath = Path.Combine(Path.GetTempPath(), myUniqueFileName); var screenshot = WebDriverHelper.TakeScreenshot(); screenshot.SaveAsFile(fullPath, ImageFormat.Png); // Attach image to the log file TestContext.AddResultFile(fullPath); } catch (Exception e) { Console.WriteLine("Unable to take screenshot:" + e.Message); } } bool shouldRestartBrowser = isTestFailed; if (shouldRestartBrowser) { WebDriverHelper.CloseDriver(); } }
public void Quit() { driverHelper.CloseDriver(); }