コード例 #1
0
        public void TearDown()
        {
            try
            {
                if (TestContext.CurrentContext.Result.Outcome == ResultState.Failure)
                {
                    extentReport.AddTestLog(Status.Fail, "Test case failed, please check logs or screenshots for failure reason");

                    string testcaseExecutionStartTime = DateUtils.GetCurrentDateAndTime();

                    string screenshotFile = $"{currentWorkingDirectory}/screenshots/test-{testcaseExecutionStartTime}.jpeg";

                    screenshotUtils.CaptureAndSaveScreenshot(screenshotFile);

                    extentReport.AddScreenshotInReport(screenshotFile);
                }
                extentReport.AddTestLog(Status.Info, "Closing all Browsers");
            }
            catch (Exception ex)
            {
                extentReport.AddTestLog(Status.Error, ex.StackTrace);
            }
            finally
            {
                cmnDriver.CloseAllBrowsers();
            }
        }
コード例 #2
0
ファイル: BaseTests.cs プロジェクト: deborazh/Telerik
        public void TearDown()
        {
            string currentExecutionTime = DateTime.Now.ToString("yyyy'-'MM'-'dd'T'HH'-'mm'-'ss");
            string screenshotFileName   = $"{currentProjectDirectory}/screenshots/test-{currentExecutionTime}.jpeg";

            if (TestContext.CurrentContext.Result.Outcome == ResultState.Failure)
            {
                extentReportUtils.addTestLog(Status.Fail, "One or more step failed");
                screenshot.CaptureAndSaveScreenshot(screenshotFileName);
                extentReportUtils.addScreenshot(screenshotFileName);
            }
            CmdDriver.CloseAllBrowser();
        }