How to use htmlReport method in backstopjs

Best JavaScript code snippet using backstopjs

CustomFunctions.js

Source:CustomFunctions.js Github

copy

Full Screen

12var overAllTestCaseStatus,listOfEnvironments = Sys.OleObject("Scripting.Dictionary");3var gLogPath,strTestCaseHTMLFilePath,S_NO,htmlreportcontent='';4var gTestCasePicPath,gPictureLogPath,executedEnvs;5var PASS_COLR = "Green", FAIL_COLOR = "Red";6var exeStartTime,exeEndTime,tcStartTime,tcEndTime,strHTMLHighLevelReport;7//set ProjectSuite Varaibles8function setProjectSuiteLevelVariables(){9 if (!ProjectSuite.Variables.VariableExists("exeStartTime"))10 ProjectSuite.Variables.AddVariable("exeStartTime","String");11 if (!ProjectSuite.Variables.VariableExists("gPictureLogPath"))12 ProjectSuite.Variables.AddVariable("gPictureLogPath","String");13 if (!ProjectSuite.Variables.VariableExists("strTestCaseHTMLFilePath"))14 ProjectSuite.Variables.AddVariable("strTestCaseHTMLFilePath","String");15 if (!ProjectSuite.Variables.VariableExists("totalTCCount"))16 ProjectSuite.Variables.AddVariable("totalTCCount","Integer");17 if (!ProjectSuite.Variables.VariableExists("passTCCount"))18 ProjectSuite.Variables.AddVariable("passTCCount","Integer");19 if (!ProjectSuite.Variables.VariableExists("failTCCount"))20 ProjectSuite.Variables.AddVariable("failTCCount","Integer");21 //add follwoing line22 ProjectSuite.Variables.failTCCount= 0, ProjectSuite.Variables.passTCCount= 0, ProjectSuite.Variables.totalTCCount = 0;23}24//set the ReportLogPath25function setLogsPath(str_PathToLogs)26{27 if(aqString.SubString(str_PathToLogs,(aqString.GetLength(str_PathToLogs)-1),aqString.GetLength(str_PathToLogs)) != "\\")28 {29 gLogPath = str_PathToLogs + "\\"; 30 }31 else32 {33 gLogPath = str_PathToLogs;34 }35 36}37//Sets StartTime of test 38function setExecutionStartTime(time_ExecutionStart)39{40 ProjectSuite.Variables.exeStartTime = time_ExecutionStart;41}42//Sets EndTime of test 43function setExecutionEndTime(time_ExecutionEnd)44{45 exeEndTime = time_ExecutionEnd; 46}47//create the report folder48function fn_createreportfolder()49{50 //Log.Message("Project Suite Path : " + ProjectSuite.Path);51 gLogPath = ProjectSuite.Path + "Results\\" + fn_getprojectSuiteName() + "_" + fn_getuniquefilename( )+ "\\";52 //ProjectSuite.Variables.gLogPath = gLogPath;53 //Log.Message(gLogPath);54}55//TestCase HTML Reports56//#########################################################################################################################################57//Create a report file 58function fn_createreportfile(executedEnvsStr){59 executedEnvs = executedEnvsStr;60 setProjectSuiteLevelVariables();61 fn_createtestcasereportfile();62 fn_createreportheader(executedEnvs)63 fn_createtestcasetable();64}65//Create report folder and filename66function fn_createtestcasereportfile()67{68 //set execution start time 69 setExecutionStartTime(aqDateTime.Now());70 if (strTestCaseHTMLFilePath== undefined){71 var tempunquePath = fn_getuniquefilename();72 fn_createreportfolder();73 // Log.Message(gLogPath);74 aqFileSystem.CreateFolder(gLogPath);75 76 // 77 gPictureLogPath = gLogPath + "Picture";78 aqFileSystem.CreateFolder(gPictureLogPath);79 gPictureLogPath = gPictureLogPath + "\\";80 ProjectSuite.Variables.gPictureLogPath = gPictureLogPath;81 82 gTestCasePicPath = "\\Picture\\";83 84 strTestCaseHTMLFilePath = gLogPath + fn_getprojectSuiteName() + "-" + tempunquePath + ".htm";85 ProjectSuite.Variables.strTestCaseHTMLFilePath = strTestCaseHTMLFilePath;86 }87}88//Create report header89function fn_createreportheader (executedEnvs){90 var htmlreport; 91 if (exeEndTime == undefined ){ setExecutionEndTime(aqDateTime.Now());}92 93 htmlreport = fn_starthtmlbodycolor("White") + fn_htmlnewline() + fn_fontstart() + fn_header("Automation Highlevel Report"); 94 htmlreport = htmlreport + fn_htmlstarttable(1) + fn_htmlcreateheaders("Project Suite Name|Executed Environments|Machine Name") ;95 htmlreport = htmlreport + fn_htmlrowdata(fn_getprojectSuiteName(),"Center","White") ;96 //htmlreport = htmlreport + fn_fontcolor("White") + "<b>" + fn_htmlrowdata( "tempOverAllStatus","Center","White") + "</b>" + fn_fontcolor("Black") ;97 htmlreport = htmlreport + fn_htmlrowdata(executedEnvs,"Center","#F5F5DC") ;98 htmlreport = htmlreport + fn_htmlrowdata(Sys.HostName,"Center","White") + fn_htmlendrow() + fn_htmlclosetable();99 100 htmlreport = htmlreport +fn_htmlnewline() + fn_htmlnewline() + fn_htmlstarttable(1) + fn_htmlcreateheaders("Execution Date|Start Time|End Time|Total Duration") ;101 102 htmlreport = htmlreport + fn_htmlrowdata(fn_formatdate(ProjectSuite.Variables.exeStartTime),"Center","White") ;103 htmlreport = htmlreport + fn_htmlrowdata(fn_formatdatetime(ProjectSuite.Variables.exeStartTime) ,"Center","White") ;104 htmlreport = htmlreport + fn_htmlrowdata(fn_formatdatetime(exeEndTime),"Center","White") ; 105 106 htmlreport = htmlreport + fn_htmlrowdata(fn_gettimediff(exeEndTime,ProjectSuite.Variables.exeStartTime),"Center","White") ;107 htmlreport = htmlreport + fn_htmlendrow() + fn_htmlclosetable() + fn_htmlnewline() + fn_htmlnewline() ;108 109 htmlreport = htmlreport + "<center>" + fn_initializeCricle("total",ProjectSuite.Variables.totalTCCount) + fn_initializeCricle("Pass",ProjectSuite.Variables.passTCCount) + fn_initializeCricle("Fail",ProjectSuite.Variables.failTCCount)110 htmlreport = htmlreport + fn_htmlnewline() + fn_htmlnewline() + fn_htmlnewline() + fn_htmlnewline() + fn_htmlnewline() + "</center>";111 htmlreport = aqString.Replace(htmlreport,"undefined","-");112 htmlreportcontent = htmlreport;113 114 115 116}117//Create testcase table header118function fn_createtestcasetable (){119 var htmlreport = " "; 120 htmlreport = htmlreport + fn_htmlnewline()+fn_htmlnewline()+fn_fontstart() + fn_htmlstarttable(1) + fn_htmlcreateheaders("Step No.|Actions|Expected Result|Actual Result|Status|Picture ") ;121 htmlreportcontent = htmlreportcontent + htmlreport;122}123//Create projectname row124function fn_createprojectnamerow (prjname){125 var prjrow; 126 prjrow = fn_htmlstartrow() + fn_htmlmergerow("<B>Project Name: </B>" + prjname,"Left","White")+ fn_htmlendrow();127 htmlreportcontent = htmlreportcontent + prjrow;128 S_NO=1;129}130//Returns Test Step131function fn_createteststep(strStatus,strRequiredAction, strExpected,strActual,wantScreenShot)132{133 var tempCode,statusColor,strImgLink="";134 135 switch (strStatus) 136 {137 case 1://PASS138 statusColor = PASS_COLR;139 strStatus = "Pass";140 Log.Checkpoint(strActual,strExpected);141 ProjectSuite.Variables.passTCCount = ProjectSuite.Variables.passTCCount + 1;142 break;143 case 0: //FAIL144 statusColor = FAIL_COLOR;145 strStatus = "Fail";146 strImgLink = fn_getscreenshotlink();147 Log.Error(strActual,strExpected);148 ProjectSuite.Variables.failTCCount = ProjectSuite.Variables.failTCCount + 1149 break; 150 } 151 ProjectSuite.Variables.totalTCCount = ProjectSuite.Variables.totalTCCount + 1; 152 if(wantScreenShot)153 {154 strImgLink = fn_getscreenshotlink(); 155 }156 157 tempCode = fn_htmlstartrow() + fn_htmlrowdata(S_NO,"Center","White") ;158 tempCode = tempCode + fn_htmlrowdata(strRequiredAction,"Left","White") ;159 tempCode = tempCode + fn_htmlrowdata(strExpected,"Left","White") ;160 tempCode = tempCode + fn_htmlrowdata(strActual,"Left","White") ;161 tempCode = tempCode + fn_htmlrowdata(strStatus,"Center",statusColor) ;162 163 if (strImgLink != "")164 {165 tempCode = tempCode + fn_htmlrowdata(fn_createlink(gTestCasePicPath) ,"Center","White") ;166 }167 else168 {169 tempCode = tempCode + fn_htmlrowdata("-" ,"Center","White") ;170 }171 tempCode = tempCode + fn_htmlendrow();172 // currentTestCaseStatus = currentTestCaseStatus + "," + strStatus;173 overAllTestCaseStatus = overAllTestCaseStatus + "," + strStatus;174 175 htmlreportcontent = htmlreportcontent +tempCode;176 S_NO = S_NO + 1;177 fn_completetestcase();178}179//Consolidate the Test Case Overview, run details and Test Steps180function fn_completetestcase()181{182 var strforHTMLReport;183 var createFile=true;184 var reportFile;185 strforHTMLReport = htmlreportcontent;186 strforHTMLReport = aqString.Replace(strforHTMLReport,"undefined","-");187 if (aqFile.Exists(ProjectSuite.Variables.strTestCaseHTMLFilePath)){188 createFile=false; 189 }190 191 if(aqFile.WriteToTextFile(ProjectSuite.Variables.strTestCaseHTMLFilePath,strforHTMLReport,20,createFile))192 {193 // Log.Message("Log created for project true");194 }195 else196 {197 // Log.Message("Log created for project false"); 198 }199 htmlreportcontent = "";200 201}202//#########################################################################################################################################203function fn_generatehighlevelreport(executedEnvs)204{205// #F5DEB3,#F5F5DC206 var htmlreport,strModuleName = "",strExecutedEnvs = "";207 setExecutionEndTime(aqDateTime.Now());208 if (executedEnvs != undefined){209 strExecutedEnvs = executedEnvs;210 }211 /* if(aqString.Find(overAllTestCaseStatus,"Fail",1) != -1)212 { 213 tempOverAllStatus = "Fail";214 tempOverAllstatusColor = FAIL_COLOR;215 }216 else if(aqString.Find(overAllTestCaseStatus,"Pass",1) != -1)217 {218 tempOverAllStatus = "Pass";219 tempOverAllstatusColor = PASS_COLR;220 }221 222 /* 223 htmlreport = fn_starthtmlbodycolor("White") + fn_htmlnewline() + fn_fontstart() + fn_header("Automation Highlevel Report"); 224 htmlreport = htmlreport + fn_htmlstarttable(1) + fn_htmlcreateheaders("Module Name(s)|OverAll Status|Executed Environments|Machine Name") ;225 htmlreport = htmlreport + fn_htmlrowdata(fn_getprojectSuiteName(),"Center","White") ;226 htmlreport = htmlreport + fn_fontcolor("White") + "<b>" + fn_htmlrowdata( tempOverAllStatus,"Center",tempOverAllstatusColor) + "</b>" + fn_fontcolor("Black") ;227 htmlreport = htmlreport + fn_htmlrowdata(executedEnvs,"Center","#F5F5DC") ;228 htmlreport = htmlreport + fn_htmlrowdata(Sys.HostName,"Center","White") + fn_htmlendrow() + fn_htmlclosetable();229 230 htmlreport = htmlreport +fn_htmlnewline() + fn_htmlnewline() + fn_htmlstarttable(1) + fn_htmlcreateheaders("Execution Date|Start Time|End Time|Total Duration") ;231 htmlreport = htmlreport + fn_htmlrowdata(fn_formatdate(ProjectSuite.Variables.exeStartTime),"Center","White") ;232 htmlreport = htmlreport + fn_htmlrowdata(fn_formatdatetime(ProjectSuite.Variables.exeStartTime) ,"Center","White") ;233 htmlreport = htmlreport + fn_htmlrowdata(fn_formatdatetime(exeEndTime),"Center","White") ; 234 htmlreport = htmlreport + fn_htmlrowdata(fn_gettimediff(exeEndTime,ProjectSuite.Variables.exeStartTime),"Center","White") ;235 htmlreport = htmlreport + fn_htmlendrow() + fn_htmlclosetable() + fn_htmlnewline() + fn_htmlnewline() ;236 237 htmlreport = htmlreport + "<center>" + fn_initializeCricle("total",ProjectSuite.Variables.totalTCCount) + fn_initializeCricle("Pass",ProjectSuite.Variables.passTCCount) + fn_initializeCricle("Fail",ProjectSuite.Variables.failTCCount)238 htmlreport = htmlreport + fn_htmlnewline() + fn_htmlnewline() + fn_htmlnewline() + fn_htmlnewline() + fn_htmlnewline() + "</center>";*/239 240 fn_createreportheader (executedEnvs); 241 242 // Log.Message("**************test filee path : " + ProjectSuite.Variables.strTestCaseHTMLFilePath + "********" );243 var myFile = aqFile.OpenTextFile(ProjectSuite.Variables.strTestCaseHTMLFilePath, aqFile.faReadWrite, 22);244 myFile.Cursor = 0; 245 myFile.WriteLine(htmlreportcontent);246 myFile.Close();247 248 htmlreportcontent = "";249 ProjectSuite.Variables.exeStartTime = "";250 ProjectSuite.Variables.failTCCount= 0, ProjectSuite.Variables.passTCCount= 0, ProjectSuite.Variables.totalTCCount = 0;251 ProjectSuite.Variables.gPictureLogPath="";ProjectSuite.Variables.strTestCaseHTMLFilePath="";252}253/*#########################################################################################################################################254*Support Libraries255#########################################################################################################################################*/256//Returns the HTML tag 257function fn_starthtmlbodycolor(strbodyColor)258{259 return "<html> <body bgcolor = " + strbodyColor + ">" + Chr(10);260}261//Returns the HTML end tag262function fn_endhtml()263{264 return " </body> </html>" + + Chr(10);265}266//Returns HTML Table267function fn_htmlstarttable(intTableType)268{269 var tempCode;270 switch ( intTableType)271 {272 case 1:273 tempCode = "<table width=" + Chr(34) + "80%" + Chr(34) + "cellspacing=" +Chr(34) + "2" + Chr(34) + " cellpadding=" + Chr(34) + "0" + Chr(34) + " border=" + Chr(34) + "0" + Chr(34) + " align=" + Chr(34) + "center" + Chr(34) + " bgcolor=" + Chr(34) + "#556B2F" + Chr(34) + " font face=" + Chr(34) + "Calibri" + Chr(34) +">" ;274 gcurtblbordercolor = "#556B2F";275 return tempCode + Chr(10); 276 break;277 case 2:278 tempCode = "<table width=" + Chr(34) + "80%" + Chr(34) + "cellspacing=" +Chr(34) + "2" + Chr(34) + " cellpadding=" + Chr(34) + "0" + Chr(34) + " border=" + Chr(34) + "0" + Chr(34) + " align=" + Chr(34) + "center" + Chr(34) + " bgcolor=" + Chr(34) + "#191970" + Chr(34) + " font face=" + Chr(34) + "Calibri" + Chr(34) +">";279 gcurtblbordercolor = "#191970";280 return tempCode + Chr(10);281 break;282 case 3:283 tempCode = "<table width=" + Chr(34) + "80%" + Chr(34) + "cellspacing=" +Chr(34) + "2" + Chr(34) + " cellpadding=" + Chr(34) + "0" + Chr(34) + " border=" + Chr(34) + "0" + Chr(34) + " align=" + Chr(34) + "center" + Chr(34) + " bgcolor=" + Chr(34) + "#000000" + Chr(34) + " font face=" + Chr(34) + "Calibri" + Chr(34) +">";284 gcurtblbordercolor = "#000000";285 return tempCode + Chr(10);286 break;287 default:288 tempCode = "<table width=" + Chr(34) + "80%" + Chr(34) + "cellspacing=" +Chr(34) + "2" + Chr(34) + " cellpadding=" + Chr(34) + "0" + Chr(34) + " border=" + Chr(34) + "0" + Chr(34) + " align=" + Chr(34) + "center" + Chr(34) + " bgcolor=" + Chr(34) + "#2F4F4F" + Chr(34) + " font face=" + Chr(34) + "Calibri" + Chr(34) +">";289 gcurtblbordercolor = "#2F4F4F"; 290 return tempCode + Chr(10);291 }292 293}294//Closing the HTML Table295function fn_htmlclosetable()296{297 var tempCode;298 tempCode = "</table>";299 return tempCode + Chr(10);300}301//Returns HTML headers302function fn_htmlcreateheaders(strHTMLHeaders)303{304 var tempCode;305 aqString.ListSeparator = "|" ;306 if(strHTMLHeaders != "")307 {308 tempCode = "<thead align = " + chr(34) + "center" + chr(34) + " bgcolor = " + chr(34) + gcurtblbordercolor + chr(34) + "> <tr> ";309 for(var i = 0; i < aqString.GetListLength(strHTMLHeaders) ; i++)310 {311 tempCode = tempCode + " <th>" + fn_fontcolor("White") + aqString.GetListItem(strHTMLHeaders,i) + "</th>";312 }313 tempCode = tempCode + " </tr> </thead>";314 return tempCode + Chr(10);315 }316 else317 {318 return "";319 } 320}321//Starting code of theHTML row 322function fn_htmlstartrow()323{ 324 return "<tr>" + Chr(10); 325}326//Merge Row 327function fn_htmlmergerow(strHTMLRowData,stralign,bgcolor)328{ 329 var tempCode;330 if(strHTMLRowData == "" )331 { 332 strHTMLRowData = "-";333 }334 tempCode = "<td colspan='6' bgcolor = " + chr(34) + "f88379" + chr(34) + "align = " + chr(34) + stralign + chr(34) + ">" + strHTMLRowData + "</td>";335 return tempCode + Chr(10);336}337//Ending code of theHTML row338function fn_htmlendrow()339{ 340 return "</tr>" + Chr(10); 341}342//Inserting row data into HTML table343function fn_htmlrowdata(strHTMLRowData,stralign,bgcolor)344{345 var tempCode;346 if(strHTMLRowData == "" )347 { 348 strHTMLRowData = "-";349 }350 tempCode = "<td bgcolor = " + chr(34) + bgcolor + chr(34) + "align = " + chr(34) + stralign + chr(34) + ">" + strHTMLRowData + "</td>";351 return tempCode + Chr(10);352}353//Returns Font tag with default font as Calibri354function fn_fontstart()355{ 356 return "<font face = " + chr(34) +"Calibri" + chr(34) + ">" + Chr(10);357}358//Ending the Font limit359function fn_fontend()360{ 361 return "</font>" + Chr(10); 362}363//Changing thefont color 364function fn_fontcolor(strColorName)365{366 var tempCode;367 tempCode = "<font color = " + chr(34) + strColorName + chr(34) + ">";368 return tempCode + Chr(10);369}370//Returns HTML Header data371function fn_header(strValue)372{373 return "<H2> <center> <font color = " + chr(34) + "#2F4F4F" + chr(34) + ">" + strValue +"</center></H2>" + Chr(10);374}375//Returns HTML new line376function fn_htmlnewline()377{378 return "<br>" + Chr(10);379}380//Returns HTML hyber link381function fn_createlink(strImgLink)382{383 var tempCode;384 tempCode = "<a href = " + chr(34) + strImgLink + chr(34) + "> View </a>";385 return tempCode + Chr(10);386}387function fn_initializeCricle(strStatus,intCount)388{389 var tempCode;390 if (intCount === 0 || aqString.GetLength(intCount)== 1 ){391 intCount = " "+intCount;392 }393 switch(strStatus)394 {395 case "Pass":396 tempCode = " Passed " + "<style type=" + chr(34) + "text/css" + chr(34) + ">" + ".passCircle { display:inline-block; border-radius:50%; border:2px solid; border-color:Green; font-size:32px;}"397 tempCode = tempCode + ".passCircle:before,.passCircle:after { content:'\\200B'; display:inline-block; line-height:0px; padding-top:50%; padding-bottom:50%;}"398 tempCode = tempCode + ".passCircle:before { padding-left:8px;}.passCircle:after { padding-right:8px;} </style>"399 tempCode = tempCode + "<span class=" + chr(34) + "passCircle" + chr(34) + ">" + intCount +"</span>"400 return tempCode + Chr(10);401 break;402 case "Fail":403 tempCode =" Failed " + "<style type=" + chr(34) + "text/css" + chr(34) + ">" + ".failCircle { display:inline-block; border-radius:50%; border:2px solid; border-color: Red; font-size:32px;}"404 tempCode = tempCode + ".failCircle:before,.failCircle:after { content:'\\200B'; display:inline-block; line-height:0px; padding-top:50%; padding-bottom:50%;}"405 tempCode = tempCode + ".failCircle:before { padding-left:8px;}.failCircle:after { padding-right:8px;} </style>" 406 tempCode = tempCode + "<span class=" + chr(34) + "failCircle" + chr(34) + ">" + intCount +"</span>"407 return tempCode + Chr(10);408 break; 409 case "total":410 tempCode = " Total Test Step(s) " + "<style type=" + chr(34) + "text/css" + chr(34) + ">" + ".totalCircle { display:inline-block; border-radius:50%; border:2px solid; border-color: Blue; font-size:36px;}"411 tempCode = tempCode + ".totalCircle:before,.totalCircle:after { content:'\\200B'; display:inline-block; line-height:0px; padding-top:50%; padding-bottom:50%;}"412 tempCode = tempCode + ".totalCircle:before { padding-left:8px;}.totalCircle:after { padding-right:8px;} </style>" 413 tempCode = tempCode + "<span class=" + chr(34) + "totalCircle" + chr(34) + ">" + intCount +"</span>"414 return tempCode + Chr(10);415 break; 416 } 417}418// Caputring Screenshot419function fn_getscreenshotlink()420{421 gTestCasePicPath = "Picture\\";422 var tempObject;423 var tempuniquename = fn_getuniquefilename();424 tempObject = ProjectSuite.Variables.gPictureLogPath + "Fail_" + tempuniquename + ".png";425 gTestCasePicPath = gTestCasePicPath + "Fail_" + tempuniquename + ".png";426 Sys.Desktop.ActiveWindow().Picture().SaveToFile(tempObject);427 return tempObject; 428}429//Returns the time difference between two time : Format 12 Hrs 30 Mins 45 Sec430function fn_gettimediff(endDate,startDate)431{432try433{434 var hrDiff,miDiff,secDiff;435 hrDiff = aqDateTime.GetHours(aqDateTime.TimeInterval(aqConvert.StrToDateTime(startDate),aqConvert.StrToDateTime(endDate)));436 miDiff = aqDateTime.GetMinutes(aqDateTime.TimeInterval(aqConvert.StrToDateTime(startDate),aqConvert.StrToDateTime(endDate)));437 secDiff = aqDateTime.GetSeconds(aqDateTime.TimeInterval(aqConvert.StrToDateTime(startDate),aqConvert.StrToDateTime(endDate)));438 return hrDiff + " Hrs " + miDiff + " Mins " + secDiff + " Sec" 439}440catch(ex)441{442 return "";443}444 445}446//Returns the Unique file name using current date and time 447function fn_getuniquefilename()448{449 var indate,inthr,intmi,intsec;450 indate = aqConvert.DateTimeToFormatStr(aqDateTime.Today(),"%b_%d_%y");451 inthr = aqDateTime.GetHours(aqDateTime.Now());452 intmi = aqDateTime.GetMinutes(aqDateTime.Now());453 intsec = aqDateTime.GetSeconds(aqDateTime.Now());454 return indate + "-" + inthr + "_" + intmi + "_" + intsec;455 456} 457//Returns the specified format of theinputed date : Format - Sep-20-2016 458function fn_formatdate(dtInput)459{460 var tempDate;461 tempDate = aqConvert.DateTimeToFormatStr(dtInput,"%b-%d-%Y");462 return tempDate;463}464//Returns the specified format of theinputed dateand time : Format - Sep-20-2016 12:30:45 AM465function fn_formatdatetime(dtInput)466{467 var tempDate;468 tempDate = aqConvert.DateTimeToFormatStr(dtInput,"%b-%d-%Y %I:%M:%S %p (%z)");469 return tempDate;470}471//Returns Project Suite Name472function fn_getprojectSuiteName(){473 //Project Suite FileName : C:\Users\akaur\Downloads\Sample_ProjectForHTMLReports\Sample_ProjectForHTMLReports.pjs474 var pjfileName = ProjectSuite.FileName.substring(ProjectSuite.FileName.lastIndexOf('\\')+1).split('.');475 return pjfileName[0];476}477//Returns Project Name478function fn_getprojectName(){479 // Log.Message("Project FileName : " + Project.FileName);480 // Project FileName : C:\Users\akaur\Downloads\Sample_ProjectForHTMLReports\Sample_ProjectForHTMLReports\Sample_ProjectForHTMLReports_Prj.mds481 var pfileName = Project.FileName.substring(Project.FileName.lastIndexOf('\\')+1).split('.');482 return pfileName[0];483 484}485//**********************************************************************************486// Common Browser functions487//**********************************************************************************488//Function to close all browsers - need improvments489/*function closeBrowser(){490 var arr = Array("iexplore", "firefox", "chrome");491 for(var i in arr) {492 while (Sys.WaitBrowser(arr[i], 500).Exists){493 var b = Sys.Browser(arr[i]);494 if (b.Exists && b.ChildCount>0 ){495 var page = b.Page("*");496 497 if (page.Exists) page.Close(); 498 }499 }500 }501}*/502//Function to close all browsers - need improvments503function closeBrowser()504{505let bArray = ["iexplore", "firefox","msedge","chrome"]; 506 for (let i = 0; i < bArray.length; i++)507{508 let b = Sys.FindChild("ProcessName", bArray[i]);509 while (b.Exists)510 {511 b.Close();512 // Checks whether the browser is closed513 if (b.Exists)514 {515 Log.Warning(b.ProcessName + " seems to hang, terminating.");516 // Terminates the browser517 b.Terminate();518 }519 // Obtains another instance of the browser520 b = Sys.FindChild("ProcessName", bArray[i]);521 }522} 523}524function closeAllBrowser(){525 var arr = Array("iexplore", "chrome","msedge");526 for(var i in arr) {527 while (Sys.WaitBrowser(arr[i], 1000).Exists){528 var b = Sys.Browser(arr[i]);529 if (b.Exists && b.ChildCount>0 ){530 var page = b.Page("*");531 if (page.Exists) page.Close(); 532 }533 }534 }535 if (Sys.WaitProcess("firefox").Exists) Sys.Process("firefox").Close();536}537function closeBrowserSpecific(browserName){538 while (Sys.WaitBrowser(browserName, 500).Exists){539 var b = Sys.Browser(browserName);540 if (b.Exists && b.ChildCount>0 ){541 var page = b.Page("*");542 if (page.Exists) page.Close(); 543 }544 }545 546}547//Function to clear Cookies548function clearBrowserCookies(){549 var objShell = getActiveXObject("WScript.Shell");550 objShell.Run("powershell RunDll32.exe InetCpl.cpl, ClearMyTracksByProcess 2");551}552//Function to launch new IE browser553function openNewIEBrowser(url){554 openNewBrowser(btIExplorer, url);555 }556 557 558 //Function to launch new Edge browser559function openNewEdgeBrowser(url){560 openNewBrowser(btEdge, url);561 }562//Function to launch new Chrome browser563function openNewCromeBrowser(url){564 openNewBrowser(btChrome, url);565}566//Function to launch new Firefox browser567function openNewFirefoxBrowser(url){568 openNewBrowser(btFirefox, url);569}570//Function to launch new browser571function openNewBrowser(browserStr, url){572 if (url == undefined) { 573 Browsers.Item(browserStr).Run();574 }else{575 Browsers.Item(browserStr).Run(url);576 }577} 578// Function to open new tab in IE579function OpenNewTab(URL)580{581 var browser = Sys.Browser();582 if ((browser.ProcessName == "iexplore"))583 584 {585 browser.BrowserWindow(0).Keys("^t");586 browser.ToUrl(URL);587 }...

Full Screen

Full Screen

HtmlReport.js

Source:HtmlReport.js Github

copy

Full Screen

1"use strict";2var __importDefault = (this && this.__importDefault) || function (mod) {3 return (mod && mod.__esModule) ? mod : { "default": mod };4};5Object.defineProperty(exports, "__esModule", { value: true });6exports.HtmlReport = void 0;7var fs_1 = __importDefault(require("fs"));8var HtmlReport = /** @class */ (function () {9 function HtmlReport() {10 }11 HtmlReport.prototype.print = function (report) {12 var html = "\n <div>\n <h1>Analysis Output</h1>\n <div>" + report + "</div>\n </div>\n ";13 fs_1.default.writeFileSync('report.html', html);14 };15 return HtmlReport;16}());...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var htmlReport = require('backstopjs/reporters/html');2htmlReport('test/reports');3var htmlReport = require('backstopjs/reporters/html');4htmlReport('test/reports');5var htmlReport = require('backstopjs/reporters/html');6htmlReport('test/reports');7var htmlReport = require('backstopjs/reporters/html');8htmlReport('test/reports');9var htmlReport = require('backstopjs/reporters/html');10htmlReport('test/reports');11var htmlReport = require('backstopjs/reporters/html');12htmlReport('test/reports');13var htmlReport = require('backstopjs/reporters/html');14htmlReport('test/reports');15var htmlReport = require('backstopjs/reporters/html');16htmlReport('test/reports');

Full Screen

Using AI Code Generation

copy

Full Screen

1var htmlReport = require('backstopjs/reporters/html');2htmlReport.createHtmlReport({3 {4 reference: {5 },6 test: {7 },8 },9 {10 reference: {11 },12 test: {13 },14 }15 {16 },17 {18 }19 {

Full Screen

Using AI Code Generation

copy

Full Screen

1var HtmlReport = require('backstopjs/htmlReport');2HtmlReport.createHtmlReport();3 {4 {5 },6 {7 },8 {9 }10 {11 }12 "paths": {13 },14 "engineOptions": {},15 }

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run backstopjs automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful