Пример #1
0
        public static void BeforeTestRun()
        {
            //Check and backup current test report then clear files in test report folder
            try
            {
                if (FrameworkUtility.CheckIfFolderContainsFiles(FrameworkUtility.GetTestReportDirectory(), "html"))
                {
                    FrameworkUtility.ZipFolderLocation(FrameworkUtility.GetTestReportDirectory(), FrameworkUtility.GetTestReportBackUpDirectory() + "TestReport" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".zip");
                    FrameworkUtility.DeleteAllFilesInFolder(FrameworkUtility.GetTestReportDirectory());
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            //Create extent report object
            extentReports = new ExtentReports();
            //Create html reporter object and define reporter path
            var htmlReporter = new ExtentV3HtmlReporter(FrameworkUtility.GetTestReportDirectory() + "TestResultsReport.html");

            //Adding html reporter to extent report object
            extentReports.AttachReporter(htmlReporter);
            extentReports.CreateTest("IGNORE");
            extentReports.AddSystemInfo("Host Name", "Local");
            extentReports.AddSystemInfo("Environment", "Local");
            htmlReporter.LoadConfig(FrameworkUtility.GetProjectBaseDirectory() + @"\extent-config.xml");

            //Create extent log object
            extentLog = new ExtentReports();
            var htmlLogger = new ExtentLoggerReporter(FrameworkUtility.GetTestReportDirectory());

            htmlLogger.LoadConfig(FrameworkUtility.GetProjectBaseDirectory() + @"\extent-config.xml");
            extentLog.AttachReporter(htmlLogger);
        }
        //adding screenshots to stepimagecontext
        public static List <StepImageContext> AddScreenshotToContext(List <StepImageContext> imageContext, string ScreenshotPathWithName, string StepInformation)
        {
            if (!ScreenshotPathWithName.Equals(""))
            {
                SeleniumHelper.CaptureScreenshotAndSave(FrameworkUtility.GetTestReportDirectory() + ScreenshotPathWithName);
            }
            StepImageContext step = new StepImageContext();

            step.ScreenshotPathWithName = ScreenshotPathWithName;
            step.StepInformation        = StepInformation;
            imageContext.Add(step);

            return(imageContext);
        }