public void GivenILaunchApplication() { BaseUtilities.applicationType = "web"; BaseUtilities.GetInitialConfigData(); dr.InitializeDriver(); Home.launchApplication(); }
public static void SetCurrentTestRunPath() { string directory = BaseUtilities.GetFolderPath(); string datetime = BaseUtilities.GetCurrentTimeWithFormat(); getCurrentTestRunPath = directory + @"\Results\Run_" + datetime; }
/// <summary> /// Report Event --> Main 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> public static void ReportEvent(string stepName, Status stepStatus, Boolean isScreenshot) { //System.Drawing.Image image = null; if (IsRequiredReport && isScreenshot) { if (BaseUtilities.applicationType != null) { if (BaseUtilities.applicationType.ToLower().Contains("web")) { if (IsDriverActive()) { Screenshot screenshot = ((ITakesScreenshot)driver).GetScreenshot(); scnshtpath = resultImgFolder + "\\"; runtimescnshtpath = scnshtpath + BaseUtilities.GetCurrentTimeWithFormat() + ".png"; screenshot.SaveAsFile(runtimescnshtpath); } } if (BaseUtilities.applicationType.ToLower().Contains("windows")) { scnshtpath = resultImgFolder + "\\"; runtimescnshtpath = scnshtpath + BaseUtilities.GetCurrentTimeWithFormat() + ".png"; TakeScreenshot(runtimescnshtpath); } } } if (isHTMLReport) { HTMLExtentReport.InsertResultStep(stepName, stepStatus, isScreenshot); } }
//public String categories, author; /// <summary> /// Initiate HTML initial setup /// </summary> public static void StartResult() { String htmlfile = "Summary Report" + ".html"; //FileStream fs = new FileStream(htmlfile, FileMode.Create); //fs.Close(); createhtmlfile = Reports.testRunResultHTMLFolder + "\\" + htmlfile; var resulthtmlfile = new FileStream(createhtmlfile, FileMode.Create); var htmlReporter = new ExtentHtmlReporter(createhtmlfile); htmlReporter.LoadConfig(BaseUtilities.GetFolderPath() + @"\Config\extent-config.xml"); // create ExtentReports and attach reporter(s) extent = new ExtentReports(); extent.AttachReporter(htmlReporter); extent.AddSystemInfo("Environment", "SysTest"); }
private void GetAxisInformation(IMsdrDataReader dataAccess) { DataUnit chromunit; DataValueType chromvalueType; IBDAChromFilter filter = new BDAChromFilter(); filter.ChromatogramType = ChromType.TotalIon; IBDAChromData[] chroms = dataAccess.GetChromatogram(filter); if (chroms.Length > 0) { chroms[0].GetXAxisInfoChrom(out chromunit, out chromvalueType); println("X Axis"); println("======"); println("Data Unit: " + BaseUtilities.GetEnumString(chromunit, true)); println("Data Value type: " + BaseUtilities.GetEnumString(chromvalueType, true)); chroms[0].GetYAxisInfoChrom(out chromunit, out chromvalueType); println("Y Axis"); println("======"); println("Data Unit: " + BaseUtilities.GetEnumString(chromunit, true)); println("Data Value type: " + BaseUtilities.GetEnumString(chromvalueType, true)); println(string.Empty); } }
/// <summary> /// Save web screenshots into result Directory --> Support Method /// </summary> /// <param name="img">ScreenShot</param> public static void SaveWebScreenshot(Screenshot img) { scnshtpath = resultImgFolder + "\\"; runtimescnshtpath = scnshtpath + BaseUtilities.GetCurrentTimeWithFormat() + ".png"; img.SaveAsFile(runtimescnshtpath); }
/// <summary> /// Save screenshots into result Directory --> Support Method /// </summary> /// <param name="img">Image</param> public static void SaveScreenshot(System.Drawing.Image img) { scnshtpath = resultImgFolder + "\\"; runtimescnshtpath = scnshtpath + BaseUtilities.GetCurrentTimeWithFormat() + ".png"; img.Save(runtimescnshtpath); }
/// <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); } }
/// <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); } }
/// <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); } }
/// <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); } }
/// <summary> /// Customize html final report /// </summary> public static void CustomizeHTMLReportOld() { var list = new List <String>(); var filestream = new FileStream(HTMLExtentReport.createhtmlfile, FileMode.Open, FileAccess.Read); using (var StreamReader = new StreamReader(filestream, Encoding.UTF8)) { String ln; while ((ln = StreamReader.ReadLine()) != null) { //customie logo and other stuff if (ln.Trim().Equals("<a href=\"http://extentreports.relevantcodes.com\" class=\"brand-logo blue darken-3\">Extent</a>")) { list.Add(" <a target='_blank' href=\"https://one.cba\" ><img src='" + BaseUtilities.GetFolderPath() + "\\Framework_Supports\\Reporting\\Images\\HTMLlogo.png' height='95%'/></a>"); } else if (ln.Trim().Contains("<span class=\"label blue darken-3\">")) { } else { list.Add(ln); } } } //Rewrite html report with customized content using (FileStream fs = new FileStream(HTMLExtentReport.createhtmlfile, FileMode.Create)) { using (StreamWriter sw = new StreamWriter(fs)) { int sr = 0; next: for (int i = sr; i < list.Count; i++) { if (list[i].Trim().Equals("<!-- search -->") && isAdded) { if (Reports.isWordReport || Reports.isPdfReport) { sw.WriteLine("<!-- Custom Report Convertion -->"); sw.WriteLine("<div class=\"chip transparent\">"); sw.WriteLine("<a class=\"dropdown-button tests-toggle\" href=\"#\" data-hover=\"false\" data-beloworigin=\"true\" data-constrainwidth=\"true\" data-activates=\"tests-toggleCus\">Report Convertion</a>"); sw.WriteLine("<ul id=\"tests-toggleCus\" class=\"dropdown-content\">"); if (Reports.isWordReport) { sw.WriteLine("<li><a data-toggle=\"modal\" data-target=\"#wordModal\">Convert to Word </a></li>"); } if (Reports.isPdfReport) { sw.WriteLine("<li><a data-toggle=\"modal\" data-target=\"#pdfModal\">Convert to Pdf </a></li>"); } sw.WriteLine(" </ul>"); sw.WriteLine("<script src=\"https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js\"></script>"); sw.WriteLine("<script src=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js\"></script>"); if (Reports.isWordReport) { sw.WriteLine("<div class=\"modal fade\" id=\"wordModal\" role=\"dialog\" >"); sw.WriteLine("<div class=\"modal-dialog\">"); sw.WriteLine(" <div class=\"modal-content\"/>"); sw.WriteLine("<div class=\"modal-header\">"); sw.WriteLine("<h4 class=\"modal-title\">Report Convertion to Word</h4>"); sw.WriteLine("</div>"); sw.WriteLine("<div class=\"modal-body\">"); sw.WriteLine("<input type=\"radio\"/>Convert report into Default Location </br>"); sw.WriteLine("<button type=\"button\" class=\"btn btn-info btn-lg\" >Convert</button>"); sw.WriteLine("<button type=\"button\" class=\"btn btn-info btn-lg\" data-dismiss=\"modal\">Close</button>"); sw.WriteLine("</div>"); sw.WriteLine("</div>"); sw.WriteLine("</div>"); sw.WriteLine("</div>"); } if (Reports.isPdfReport) { sw.WriteLine("<div class=\"modal fade\" id=\"pdfModal\" role=\"dialog\" >"); sw.WriteLine("<div class=\"modal-dialog\">"); sw.WriteLine("<div class=\"modal-content\"/>"); sw.WriteLine("<div class=\"modal-header\">"); sw.WriteLine("<h4 class=\"modal-title\">Report Convertion to PDF</h4>"); sw.WriteLine("</div>"); sw.WriteLine("<div class=\"modal-body\">"); sw.WriteLine("<input type=\"radio\"/>Convert report into Default Location </br>"); sw.WriteLine("<button type=\"button\" class=\"btn btn-info btn-lg\" >Convert</button>"); sw.WriteLine("<button type=\"button\" class=\"btn btn-info btn-lg\" data-dismiss=\"modal\">Close</button>"); sw.WriteLine("</div>"); sw.WriteLine("</div>"); sw.WriteLine("</div>"); sw.WriteLine(" </div>"); } sw.WriteLine("</div>"); sw.WriteLine("<!-- Custom Report Convertion -->"); } sw.WriteLine(list[i]); sr = i + 1; isAdded = false; goto next; } else { sw.WriteLine(list[i]); } } } } }