Esempio n. 1
0
        /// <summary>
        /// Initialize PDF Report --> Support Method
        /// </summary>
        public static void InsertSummaryResultPDF()
        {
            try
            {
                Font date           = new Font(FontFactory.GetFont(BaseFont.COURIER, 8, new BaseColor(1, 74, 73)));
                Font heading        = new Font(FontFactory.GetFont(BaseFont.COURIER, 15, new BaseColor(1, 91, 168)));
                Font link           = new Font(FontFactory.GetFont(BaseFont.COURIER, 11, new BaseColor(1, 91, 168)));
                Font subTitleFont   = new Font(FontFactory.GetFont(BaseFont.COURIER, 11, Font.BOLD));
                Font tabledata      = new Font(FontFactory.GetFont(BaseFont.COURIER, 11));
                Font passstep       = new Font(FontFactory.GetFont(BaseFont.COURIER, 11, new BaseColor(52, 168, 83)));
                Font warningstep    = new Font(FontFactory.GetFont(BaseFont.COURIER, 11, new BaseColor(251, 188, 5)));
                Font failstep       = new Font(FontFactory.GetFont(BaseFont.COURIER, 11, new BaseColor(234, 67, 53)));
                Font subpassstep    = new Font(FontFactory.GetFont(BaseFont.COURIER, 11, new BaseColor(52, 168, 83)));
                Font subwarningstep = new Font(FontFactory.GetFont(BaseFont.COURIER, 11, new BaseColor(251, 188, 5)));
                Font subfailstep    = new Font(FontFactory.GetFont(BaseFont.COURIER, 11, new BaseColor(234, 67, 53)));

                PdfPTable table = new PdfPTable(4);
                table.WidthPercentage = 100;
                int[] tblWidth = { 3, 18, 6, 8 };
                table.SetWidths(tblWidth);

                Paragraph Sno          = new Paragraph(smrw.ToString(), tabledata);
                Paragraph ScenarioName = new Paragraph(BaseUtilities.scenarioName, tabledata);
                Anchor    anchor       = new Anchor("Click here", link);
                anchor.Reference = "file:///" + reportpath;
                //Paragraph Fmi = new Paragraph("Click here", link);

                table.AddCell(Sno);
                smrw += 1;
                table.AddCell(ScenarioName);
                switch (BaseUtilities.scenarioStatus.ToLower())
                {
                case "pass":
                    Paragraph _Teststatus = new Paragraph("Pass", passstep);
                    table.AddCell(_Teststatus);
                    break;

                case "fail":
                    Paragraph _Teststatusfl = new Paragraph("Fail", failstep);

                    table.AddCell(_Teststatusfl);
                    break;
                }

                table.AddCell(anchor);


                SummaryPDFdocument.Add(table);

                //SummaryPDFdocument.NewPage();
            }
            catch (Exception e)
            {
                Reports.SetupErrorLog(e);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Initialize Word Report --> Support Method
        /// </summary>
        public static void InsertSummaryResults()
        {
            try
            {
                Table table = resultSummarydocument.AddTable(1, 4);
                // Specify some properties for this Table.
                table.Alignment = Alignment.left;
                table.AutoFit   = AutoFit.Contents;
                table.Design    = TableDesign.TableGrid;
                table.SetColumnWidth(0, 667.87);
                table.SetColumnWidth(1, 5347.87);
                table.SetColumnWidth(2, 1255.87);
                table.SetColumnWidth(3, 1825.82);

                table.Rows[0].Cells[0].Paragraphs.First().Append(smrw.ToString() + ".");
                smrw += 1;
                table.Rows[0].Cells[1].Paragraphs.First().Append(BaseUtilities.scenarioName);
                switch (BaseUtilities.scenarioStatus.ToLower())
                {
                case "pass":

                    table.Rows[0].Cells[2].Paragraphs.First().Append("Pass").Color(System.Drawing.Color.FromArgb(52, 168, 83));
                    break;

                case "fail":

                    table.Rows[0].Cells[2].Paragraphs.First().Append("Fail").Color(System.Drawing.Color.FromArgb(234, 67, 53));
                    break;

                case "skip":

                    table.Rows[0].Cells[2].Paragraphs.First().Append("Skip").Color(System.Drawing.Color.FromArgb(234, 67, 53));
                    break;
                }


                Hyperlink link = resultSummarydocument.AddHyperlink("Click here", new Uri(reportpath));
                table.Rows[0].Cells[3].Paragraphs.First().AppendHyperlink(link).Color(System.Drawing.Color.FromArgb(1, 91, 168));

                resultSummarydocument.InsertTable(table);

                resultSummarydocument.Save();
            }
            catch (Exception e)
            {
                Reports.SetupErrorLog(e);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Initialize PDF Report --> Support Method
        /// </summary>
        public static void SummarizeTimeResultPDF()
        {
            try
            {
                Font date           = new Font(FontFactory.GetFont(BaseFont.COURIER, 8, new BaseColor(1, 74, 73)));
                Font heading        = new Font(FontFactory.GetFont(BaseFont.COURIER, 15, new BaseColor(1, 91, 168)));
                Font link           = new Font(FontFactory.GetFont(BaseFont.COURIER, 11, new BaseColor(1, 91, 168)));
                Font subTitleFont   = new Font(FontFactory.GetFont(BaseFont.COURIER, 11, Font.BOLD));
                Font tabledata      = new Font(FontFactory.GetFont(BaseFont.COURIER, 11));
                Font passstep       = new Font(FontFactory.GetFont(BaseFont.COURIER, 11, new BaseColor(52, 168, 83)));
                Font warningstep    = new Font(FontFactory.GetFont(BaseFont.COURIER, 11, new BaseColor(251, 188, 5)));
                Font failstep       = new Font(FontFactory.GetFont(BaseFont.COURIER, 11, new BaseColor(234, 67, 53)));
                Font subpassstep    = new Font(FontFactory.GetFont(BaseFont.COURIER, 11, new BaseColor(52, 168, 83)));
                Font subwarningstep = new Font(FontFactory.GetFont(BaseFont.COURIER, 11, new BaseColor(251, 188, 5)));
                Font subfailstep    = new Font(FontFactory.GetFont(BaseFont.COURIER, 11, new BaseColor(234, 67, 53)));

                SummaryPDFdocument.Add(Chunk.NEWLINE);
                PdfPTable table = new PdfPTable(4);
                table.WidthPercentage = 100;
                int[] tblWidth = { 5, 9, 9, 7 };
                table.SetWidths(tblWidth);

                Paragraph ttl     = new Paragraph("Total Count", subTitleFont);
                Paragraph sttime  = new Paragraph("Start Time", subTitleFont);
                Paragraph endtime = new Paragraph("End Time", subTitleFont);
                Paragraph ttltime = new Paragraph("Time Taken", subTitleFont);
                table.AddCell(ttl);

                table.AddCell(sttime);
                table.AddCell(endtime);
                table.AddCell(ttltime);
                table.AddCell(new Paragraph((smrw - 1).ToString(), tabledata));
                table.AddCell(new Paragraph(Reports.smrystarttime, tabledata));
                table.AddCell(new Paragraph(Reports.smryendtime, tabledata));
                table.AddCell(new Paragraph(Reports.smrytimetaken, tabledata));

                SummaryPDFdocument.Add(table);


                //SummaryPDFdocument.NewPage();
            }
            catch (Exception e)
            {
                Reports.SetupErrorLog(e);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Initialize Word Report --> Support Method
        /// </summary>
        public static void SummarizeTimeWord()
        {
            try
            {
                Paragraph last = resultSummarydocument.InsertParagraph();
                last.AppendLine();
                last.AppendLine();

                String[] Tableheading = { "Total Count", "Start Time", "End Time", "Total Time Taken" };
                String[] Tabledata    = { (smrw - 1).ToString(), Reports.smrystarttime, Reports.smryendtime, Reports.smrytimetaken };

                Table table = resultSummarydocument.AddTable(2, 4);
                // Specify some properties for this Table.
                table.Alignment = Alignment.left;
                table.AutoFit   = AutoFit.Contents;
                table.Design    = TableDesign.TableGrid;
                table.SetColumnWidth(0, 1335.74);
                table.SetColumnWidth(1, 2732.83);
                table.SetColumnWidth(2, 2732.84);
                table.SetColumnWidth(3, 2323.84);

                table.Rows[0].Cells[0].Paragraphs.First().Append(Tableheading[0]).Bold();
                table.Rows[0].Cells[1].Paragraphs.First().Append(Tableheading[1]).Bold();
                table.Rows[0].Cells[2].Paragraphs.First().Append(Tableheading[2]).Bold();
                table.Rows[0].Cells[3].Paragraphs.First().Append(Tableheading[3]).Bold();
                table.Rows[1].Cells[0].Paragraphs.First().Append(Tabledata[0]);
                table.Rows[1].Cells[1].Paragraphs.First().Append(Tabledata[1]);
                table.Rows[1].Cells[2].Paragraphs.First().Append(Tabledata[2]);
                table.Rows[1].Cells[3].Paragraphs.First().Append(Tabledata[3]);

                resultSummarydocument.InsertTable(table);


                resultSummarydocument.Save();
            }
            catch (Exception e)
            {
                Reports.SetupErrorLog(e);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Initialize Word Report --> Support Method
        /// </summary>
        public static void InitWordSummarySetup()
        {
            try
            {
                string directory = BaseUtilities.GetFolderPath();

                resultSummarydocument = DocX.Create(Reports.testRunResultWordFolder + "\\" + "Summary Report.docx");
                //Resultdocument = DocX.Create(directory + @"Results\WordResults\Testrr.docx");

                resultSummarydocument.AddHeaders();
                Header ResultHeader = resultSummarydocument.Headers.Odd;

                Image   Headerimage = resultSummarydocument.AddImage(Reports.reportheaderimage);
                Picture picture     = Headerimage.CreatePicture();
                picture.Width  = 150;
                picture.Height = 28;
                Paragraph Header = ResultHeader.InsertParagraph();
                Header.Alignment = Alignment.right;
                Header.AppendPicture(picture);

                Paragraph Date    = resultSummarydocument.InsertParagraph();
                String    StrDate = System.DateTime.Today.ToString("dd-MM-yyyy");
                Paragraph date    = Date.Append("Date: " + StrDate).FontSize(8).Font("Calibri").Color(System.Drawing.Color.FromArgb(1, 74, 73, 71));
                date.Alignment = Alignment.left;

                Paragraph title = resultSummarydocument.InsertParagraph().Append(Reports.reportname).FontSize(12).Font("Century Gothic").Color(System.Drawing.Color.FromArgb(1, 91, 168));
                title.Alignment = Alignment.center;
                title.AppendLine();
                Paragraph tcscountpass = resultSummarydocument.InsertParagraph().Append("Total Test(s) Passed: " + Reports.ttltcspass).Color(System.Drawing.Color.FromArgb(52, 168, 83));
                tcscountpass.Alignment = Alignment.left;
                Paragraph tcscountfail = resultSummarydocument.InsertParagraph().Append("Total Test(s) Failed: " + Reports.ttltcsfail).Color(System.Drawing.Color.FromArgb(234, 67, 53));
                tcscountfail.Alignment = Alignment.left;
                tcscountfail.AppendLine();

                String[] Tableheading = { "S.No", "Scenario Name", "Test Status", "For More Details" };
                String[] Tabledata    = { BaseUtilities.scenarioName, BaseUtilities.scenarioStatus };

                Table table = resultSummarydocument.AddTable(1, 4);
                // Specify some properties for this Table.
                table.Alignment = Alignment.left;
                table.AutoFit   = AutoFit.Contents;
                table.Design    = TableDesign.TableGrid;
                table.SetColumnWidth(0, 667.87);
                table.SetColumnWidth(1, 5347.87);
                table.SetColumnWidth(2, 1255.87);
                table.SetColumnWidth(3, 1825.82);

                table.Rows[0].Cells[0].Paragraphs.First().Append(Tableheading[0]).Bold();
                table.Rows[0].Cells[1].Paragraphs.First().Append(Tableheading[1]).Bold();
                table.Rows[0].Cells[2].Paragraphs.First().Append(Tableheading[2]).Bold();
                table.Rows[0].Cells[3].Paragraphs.First().Append(Tableheading[3]).Bold();


                resultSummarydocument.InsertTable(table);

                resultSummarydocument.AddFooters();
                Footer    footer_default = resultSummarydocument.Footers.Odd;
                Paragraph footer         = footer_default.InsertParagraph();
                footer.Append(Reports.reportfooterName);

                resultSummarydocument.Save();
            }
            catch (Exception e)
            {
                Reports.SetupErrorLog(e);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Insert Word Results for each step --> Support Method
        /// </summary>
        /// <param name="StepName">Name of the step</param>
        /// <param name="Stepdescription">Description of the step</param>
        /// <param name="Stepstatus">Status of the step</param>
        /// <param name="img">Step image</param>
        public static void InsertWordResults(string StepName, Status Stepstatus)
        {
            try
            {
                Paragraph title1 = resultdocument.InsertParagraph().Append("Step Name: " + StepName).FontSize(12).Font("Calibri").Color(System.Drawing.Color.FromArgb(0, 0, 0));

                Paragraph title2 = null;
                Paragraph title3 = null;

                switch (Stepstatus)
                {
                case Status.Pass:
                    title2 = resultdocument.InsertParagraph().Append("Step Status: Passed").FontSize(12).Font("Calibri").Color(System.Drawing.Color.FromArgb(52, 168, 83));
                    break;

                case Status.Warning:
                    title2 = resultdocument.InsertParagraph().Append("Step Status: Warning").FontSize(12).Font("Calibri").Color(System.Drawing.Color.FromArgb(251, 188, 5));
                    break;

                case Status.Fail:
                    title2 = resultdocument.InsertParagraph().Append("Step Status: Failed").FontSize(12).Font("Calibri").Color(System.Drawing.Color.FromArgb(234, 67, 53));
                    title3 = resultdocument.InsertParagraph().Append("Error Message: " + Reports.errorMessage).FontSize(12).Font("Calibri").Color(System.Drawing.Color.FromArgb(234, 67, 53));
                    break;

                case Status.Information:
                    title2 = resultdocument.InsertParagraph().Append("Step Status: Information").FontSize(12).Font("Calibri").Color(System.Drawing.Color.FromArgb(0, 0, 225));
                    break;

                case Status.Error:
                    title2 = resultdocument.InsertParagraph().Append("Step Status: Error").FontSize(12).Font("Calibri").Color(System.Drawing.Color.FromArgb(234, 67, 53));
                    break;

                case Status.Skip:
                    title2 = resultdocument.InsertParagraph().Append("Step Status: Skip").FontSize(12).Font("Calibri").Color(System.Drawing.Color.FromArgb(102, 225, 178));
                    break;
                }

                title1.Alignment = Alignment.left;
                Paragraph step = resultdocument.InsertParagraph();
                step.AppendLine();
                if (!string.IsNullOrEmpty(Reports.runtimescnshtpath))
                {
                    string WordImg = Reports.getCurrentTestRunPath + Reports.runtimescnshtpath.Replace("..", "");
                    Image  image   = resultdocument.AddImage(WordImg);

                    Picture picture = image.CreatePicture();
                    picture.Width  = 600;
                    picture.Height = 330;
                    step.AppendPicture(picture);
                }
                if (temp > 1)
                {
                    for (int i = 0; i <= 4; i++)
                    {
                        step.AppendLine();
                        resultdocument.Save();
                    }
                    temp = 1;
                }
                else
                {
                    step.AppendLine();
                    resultdocument.Save();
                    temp = temp + 1;
                }
            }
            catch (Exception e)
            {
                Reports.SetupErrorLog(e);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Initialize Word Report --> Support Method
        /// </summary>
        public static void InitSetupWord()
        {
            try
            {
                string directory = BaseUtilities.GetFolderPath();
                SetReportpath();
                resultdocument = DocX.Create(reportpath);
                //Resultdocument = DocX.Create(directory + @"Results\WordResults\Testrr.docx");

                resultdocument.AddHeaders();
                Header ResultHeader = resultdocument.Headers.Odd;

                Image   Headerimage = resultdocument.AddImage(Reports.reportheaderimage);
                Picture picture     = Headerimage.CreatePicture();
                picture.Width  = 150;
                picture.Height = 28;
                Paragraph Header = ResultHeader.InsertParagraph();
                Header.Alignment = Alignment.right;
                Header.AppendPicture(picture);

                Paragraph Date    = resultdocument.InsertParagraph();
                String    StrDate = System.DateTime.Today.ToString("dd-MM-yyyy");
                Paragraph date    = Date.Append("Date: " + StrDate).FontSize(8).Font("Calibri").Color(System.Drawing.Color.FromArgb(1, 74, 73, 71));
                date.Alignment = Alignment.left;



                Paragraph title = resultdocument.InsertParagraph().Append("Test Case Results").FontSize(20).Font("Century Gothic").Color(System.Drawing.Color.FromArgb(1, 91, 168));
                title.Alignment = Alignment.center;
                title.AppendLine();

                String[] Tableheading = { "Feature Name", "ALM TestSet Name", "Scenario Name", "Start Time", "End Time", "Time Taken", "Test Status" };
                String[] Tabledata    = { BaseUtilities.featureFileName, BaseUtilities.testSetName, BaseUtilities.scenarioName, Reports.starttime, Reports.endtime, Reports.timetaken, BaseUtilities.scenarioStatus };

                Table table = resultdocument.AddTable(Tableheading.Length, 2);
                // Specify some properties for this Table.
                table.Alignment = Alignment.center;
                table.AutoFit   = AutoFit.Contents;
                table.Design    = TableDesign.TableGrid;


                for (int row = 0; row < Tableheading.Length; row++)
                {
                    if (Tableheading[row].Trim().ToLower() == "test status")
                    {
                        switch (Tabledata[row].ToLower())
                        {
                        case "pass":

                            table.Rows[row].Cells[0].Paragraphs.First().Append(Tableheading[row]).Bold().Color(System.Drawing.Color.FromArgb(52, 168, 83));
                            table.Rows[row].Cells[1].Paragraphs.First().Append(Tabledata[row]).Color(System.Drawing.Color.FromArgb(52, 168, 83));
                            break;

                        case "fail":
                            table.Rows[row].Cells[0].Paragraphs.First().Append(Tableheading[row]).Bold().Color(System.Drawing.Color.FromArgb(234, 67, 53));
                            table.Rows[row].Cells[1].Paragraphs.First().Append(Tabledata[row]).Color(System.Drawing.Color.FromArgb(234, 67, 53));
                            break;

                        case "skip":
                            table.Rows[row].Cells[0].Paragraphs.First().Append(Tableheading[row]).Bold().Color(System.Drawing.Color.FromArgb(234, 67, 53));
                            table.Rows[row].Cells[1].Paragraphs.First().Append(Tabledata[row]).Color(System.Drawing.Color.FromArgb(234, 67, 53));
                            break;
                        }
                    }
                    else
                    {
                        table.Rows[row].Cells[0].Paragraphs.First().Append(Tableheading[row]).Bold();
                        table.Rows[row].Cells[1].Paragraphs.First().Append(Tabledata[row]);
                    }
                }

                resultdocument.InsertTable(table);
                Paragraph p1 = resultdocument.InsertParagraph();
                p1.AppendLine();
                p1.AppendLine();
                resultdocument.AddFooters();
                Footer    footer_default = resultdocument.Footers.Odd;
                Paragraph footer         = footer_default.InsertParagraph();
                footer.Append(Reports.reportfooterName);

                Paragraph last = resultdocument.InsertParagraph();

                for (int newline = 0; newline <= 36; newline++)
                {
                    last.AppendLine();
                }
                resultdocument.Save();
            }
            catch (Exception e)
            {
                Reports.SetupErrorLog(e);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Initialize PDF Report --> Support Method
        /// </summary>
        public static void InitSummarySetupPDF()
        {
            try
            {
                string directory = BaseUtilities.GetFolderPath();
                SummaryPDFdocument = new Document(PageSize.A4, 50, 50, 25, 25);

                var output = new FileStream(Reports.testRunResultPDFFolder + "\\Summary Report.pdf", FileMode.Create);
                var writer = PdfWriter.GetInstance(SummaryPDFdocument, output);
                SummaryPDFdocument.Open();

                Font date           = new Font(FontFactory.GetFont(BaseFont.COURIER, 8, new BaseColor(1, 74, 73)));
                Font heading        = new Font(FontFactory.GetFont(BaseFont.COURIER, 15, new BaseColor(1, 91, 168)));
                Font subTitleFont   = new Font(FontFactory.GetFont(BaseFont.COURIER, 11, Font.BOLD));
                Font tabledata      = new Font(FontFactory.GetFont(BaseFont.COURIER, 11));
                Font passstep       = new Font(FontFactory.GetFont(BaseFont.COURIER, 11, new BaseColor(52, 168, 83)));
                Font warningstep    = new Font(FontFactory.GetFont(BaseFont.COURIER, 11, new BaseColor(251, 188, 5)));
                Font failstep       = new Font(FontFactory.GetFont(BaseFont.COURIER, 11, new BaseColor(234, 67, 53)));
                Font subpassstep    = new Font(FontFactory.GetFont(BaseFont.COURIER, 11, new BaseColor(52, 168, 83)));
                Font subwarningstep = new Font(FontFactory.GetFont(BaseFont.COURIER, 11, new BaseColor(251, 188, 5)));
                Font subfailstep    = new Font(FontFactory.GetFont(BaseFont.COURIER, 11, new BaseColor(234, 67, 53)));


                var logo = iTextSharp.text.Image.GetInstance(Reports.reportheaderimage);
                logo.ScaleToFit(150, 28);
                logo.Alignment = Element.ALIGN_RIGHT;

                SummaryPDFdocument.Add(logo);

                String    StrDate   = System.DateTime.Today.ToString("dd-MM-yyyy");
                Paragraph emptyline = new Paragraph(" ", tabledata);
                emptyline.Alignment = Element.ALIGN_LEFT;
                Paragraph Pdate = new Paragraph("Date: " + StrDate, date);
                SummaryPDFdocument.Add(Pdate);

                Paragraph heading1 = new Paragraph(Reports.reportname, heading);
                heading1.Alignment = Element.ALIGN_CENTER;

                SummaryPDFdocument.Add(heading1);
                //SummaryPDFdocument.Add(Chunk.NEWLINE);
                Paragraph ttlctcspass = new Paragraph("Total Test(s) Passed: " + Reports.ttltcspass, passstep);
                ttlctcspass.Alignment = Element.ALIGN_LEFT;
                SummaryPDFdocument.Add(ttlctcspass);
                Paragraph ttlctcsfail = new Paragraph("Total Test(s) Failed: " + Reports.ttltcsfail, failstep);
                ttlctcsfail.Alignment = Element.ALIGN_LEFT;
                SummaryPDFdocument.Add(ttlctcsfail);
                SummaryPDFdocument.Add(emptyline);
                PdfPTable table = new PdfPTable(4);
                table.WidthPercentage = 100;
                int[] tblWidth = { 3, 18, 6, 8 };
                table.SetWidths(tblWidth);
                //table.HorizontalAlignment = Element.ALIGN_LEFT;
                Paragraph Sno          = new Paragraph("S.No", subTitleFont);
                Paragraph ScenarioName = new Paragraph("Scenario Name", subTitleFont);
                Paragraph Teststatus   = new Paragraph("Test Status", subTitleFont);
                Paragraph Fmi          = new Paragraph("For More Details", subTitleFont);
                table.AddCell(Sno);

                table.AddCell(ScenarioName);
                table.AddCell(Teststatus);
                table.AddCell(Fmi);


                SummaryPDFdocument.Add(table);

                //SummaryPDFdocument.NewPage();
                //PDFReport.PDFdocument.Close();
            }
            catch (Exception e)
            {
                Reports.SetupErrorLog(e);
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Insert PDF Results for each step --> Support Method
        /// </summary>
        /// <param name="StepName">Name of the step</param>
        /// <param name="Stepdescription">Description of the step</param>
        /// <param name="Stepstatus">Status of the step</param>
        /// <param name="img">Step image</param>
        public static void InsertPDFResults(string StepName, Status Stepstatus)
        {
            try
            {
                Font passstep    = new Font(FontFactory.GetFont(BaseFont.COURIER, 9, new BaseColor(52, 168, 83)));
                Font warningstep = new Font(FontFactory.GetFont(BaseFont.COURIER, 9, new BaseColor(251, 188, 5)));
                Font failstep    = new Font(FontFactory.GetFont(BaseFont.COURIER, 9, new BaseColor(234, 67, 53)));
                Font step        = new Font(FontFactory.GetFont(BaseFont.COURIER, 9, new BaseColor(0, 0, 0)));
                Font infostep    = new Font(FontFactory.GetFont(BaseFont.COURIER, 9, new BaseColor(0, 0, 225)));
                Font skipstep    = new Font(FontFactory.GetFont(BaseFont.COURIER, 9, new BaseColor(102, 225, 178)));

                Paragraph Stepname = new Paragraph("Step Name: " + StepName, step);
                Stepname.Alignment = Element.ALIGN_LEFT;
                PDFdocument.Add(Stepname);

                Paragraph PStepStatus = null;
                Paragraph errormsg    = null;


                switch (Stepstatus)
                {
                case Status.Pass:
                    PStepStatus           = new Paragraph("Step Status: Passed", passstep);
                    PStepStatus.Alignment = Element.ALIGN_LEFT;
                    PDFdocument.Add(PStepStatus);
                    PDFdocument.Add(Chunk.NEWLINE);
                    break;

                case Status.Warning:
                    PStepStatus           = new Paragraph("Step Status: Warning", warningstep);
                    PStepStatus.Alignment = Element.ALIGN_LEFT;
                    PDFdocument.Add(PStepStatus);
                    PDFdocument.Add(Chunk.NEWLINE);
                    break;

                case Status.Fail:
                    PStepStatus           = new Paragraph("Step Status: Failed", failstep);
                    PStepStatus.Alignment = Element.ALIGN_LEFT;
                    PDFdocument.Add(PStepStatus);
                    errormsg           = new Paragraph("Error Message: " + Reports.errorMessage, failstep);
                    errormsg.Alignment = Element.ALIGN_LEFT;
                    PDFdocument.Add(errormsg);
                    PDFdocument.NewPage();
                    break;

                case Status.Information:
                    PStepStatus           = new Paragraph("Step Status: Information", infostep);
                    PStepStatus.Alignment = Element.ALIGN_LEFT;
                    PDFdocument.Add(PStepStatus);
                    PDFdocument.Add(Chunk.NEWLINE);
                    break;

                case Status.Skip:
                    PStepStatus           = new Paragraph("Step Status: Information", skipstep);
                    PStepStatus.Alignment = Element.ALIGN_LEFT;
                    PDFdocument.Add(PStepStatus);
                    PDFdocument.Add(Chunk.NEWLINE);
                    break;

                case Status.Error:
                    PStepStatus           = new Paragraph("Step Status: Information", failstep);
                    PStepStatus.Alignment = Element.ALIGN_LEFT;
                    PDFdocument.Add(PStepStatus);
                    PDFdocument.Add(Chunk.NEWLINE);
                    break;
                }


                //var images = iTextSharp.text.Image.GetInstance(BaseUtilities.scnshtpath + BaseUtilities.scnshtdatetime + ".png");
                if (!string.IsNullOrEmpty(Reports.runtimescnshtpath))
                {
                    string PDFImg = Reports.getCurrentTestRunPath + Reports.runtimescnshtpath.Replace("..", "");
                    var    images = iTextSharp.text.Image.GetInstance(PDFImg);
                    images.ScaleToFit(590, 300);
                    images.Alignment = Element.ALIGN_CENTER;
                    PDFdocument.Add(images);
                    PDFdocument.Add(Chunk.NEWLINE);
                }
                PDFdocument.Add(Chunk.NEWLINE);
                if (Temp > 1)
                {
                    for (int i = 0; i <= 5; i++)
                    {
                        PDFdocument.Add(Chunk.NEWLINE);
                    }
                    Temp = 1;
                }

                else
                {
                    PDFdocument.Add(Chunk.NEWLINE);
                    Temp = Temp + 1;
                }
            }
            catch (Exception e)
            {
                Reports.SetupErrorLog(e);
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Initialize PDF Report --> Support Method
        /// </summary>
        public static void InitSetupPDF()
        {
            try
            {
                string directory = BaseUtilities.GetFolderPath();
                PDFdocument = new Document(PageSize.A4, 50, 50, 25, 25);
                SetReportpath();
                var output = new FileStream(reportpath, FileMode.Create);
                var writer = PdfWriter.GetInstance(PDFdocument, output);
                PDFdocument.Open();

                Font date           = new Font(FontFactory.GetFont(BaseFont.COURIER, 8, new BaseColor(1, 74, 73)));
                Font heading        = new Font(FontFactory.GetFont(BaseFont.COURIER, 20, new BaseColor(1, 91, 168)));
                Font subTitleFont   = new Font(FontFactory.GetFont(BaseFont.COURIER, 11, Font.BOLD));
                Font tabledata      = new Font(FontFactory.GetFont(BaseFont.COURIER, 11));
                Font passstep       = new Font(FontFactory.GetFont(BaseFont.COURIER, 11, new BaseColor(52, 168, 83)));
                Font warningstep    = new Font(FontFactory.GetFont(BaseFont.COURIER, 11, new BaseColor(251, 188, 5)));
                Font failstep       = new Font(FontFactory.GetFont(BaseFont.COURIER, 11, new BaseColor(234, 67, 53)));
                Font subpassstep    = new Font(FontFactory.GetFont(BaseFont.COURIER, 11, new BaseColor(52, 168, 83)));
                Font subwarningstep = new Font(FontFactory.GetFont(BaseFont.COURIER, 11, new BaseColor(251, 188, 5)));
                Font subfailstep    = new Font(FontFactory.GetFont(BaseFont.COURIER, 11, new BaseColor(234, 67, 53)));

                var logo = iTextSharp.text.Image.GetInstance(Reports.reportheaderimage);
                logo.ScaleToFit(150, 28);
                logo.Alignment = Element.ALIGN_RIGHT;

                PDFdocument.Add(logo);

                String StrDate = System.DateTime.Today.ToString("dd-MM-yyyy");

                Paragraph Pdate = new Paragraph("Date: " + StrDate, date);
                PDFdocument.Add(Pdate);
                Paragraph emptyline = new Paragraph("  ", tabledata);
                emptyline.Alignment = Element.ALIGN_CENTER;
                Paragraph heading1 = new Paragraph("Test Case Results", heading);
                heading1.Alignment = Element.ALIGN_CENTER;
                PDFdocument.Add(Chunk.NEWLINE);
                PDFdocument.Add(heading1);
                PDFdocument.Add(emptyline);
                PdfPTable table    = new PdfPTable(2);
                int[]     tblWidth = { 9, 20 };
                table.SetWidths(tblWidth);
                Paragraph FeatureName  = new Paragraph("Feature Name", subTitleFont);
                Paragraph TestSetName  = new Paragraph("ALM TestSet Name", subTitleFont);
                Paragraph ScenarioName = new Paragraph("Scenario Name", subTitleFont);
                Paragraph Starttime    = new Paragraph("Start Time", subTitleFont);
                Paragraph Endtime      = new Paragraph("End Time", subTitleFont);
                Paragraph Timetaken    = new Paragraph("Time Taken", subTitleFont);



                Paragraph _FeatureName  = new Paragraph(BaseUtilities.featureFileName, tabledata);
                Paragraph _TestSetName  = new Paragraph(BaseUtilities.testSetName, tabledata);
                Paragraph _ScenarioName = new Paragraph(BaseUtilities.scenarioName, tabledata);
                Paragraph _Starttime    = new Paragraph(Reports.starttime, tabledata);;
                Paragraph _Endtime      = new Paragraph(Reports.endtime, tabledata);
                Paragraph _Timetaken    = new Paragraph(Reports.timetaken, tabledata);



                table.AddCell(FeatureName);
                table.AddCell(_FeatureName);
                table.AddCell(TestSetName);
                table.AddCell(_TestSetName);

                table.AddCell(ScenarioName);
                table.AddCell(_ScenarioName);

                table.AddCell(Starttime);
                table.AddCell(_Starttime);

                table.AddCell(Endtime);
                table.AddCell(_Endtime);

                table.AddCell(Timetaken);
                table.AddCell(_Timetaken);
                switch (BaseUtilities.scenarioStatus.ToLower())
                {
                case "pass":
                    Paragraph Teststatus  = new Paragraph("Test Status", passstep);
                    Paragraph _Teststatus = new Paragraph("Pass", passstep);
                    table.AddCell(Teststatus);
                    table.AddCell(_Teststatus);
                    break;

                case "fail":
                    Paragraph Teststatusfl  = new Paragraph("Test Status", failstep);
                    Paragraph _Teststatusfl = new Paragraph("Fail", failstep);
                    table.AddCell(Teststatusfl);
                    table.AddCell(_Teststatusfl);
                    break;
                }



                PDFdocument.Add(table);

                PDFdocument.NewPage();
                //PDFReport.PDFdocument.Close();
            }
            catch (Exception e)
            {
                Reports.SetupErrorLog(e);
            }
        }