public static Boolean driveFromExcel(string excelfilePath) { try { DataTable dtResultSummary = new DataTable(); dtResultSummary.Columns.Add("SNO"); dtResultSummary.Columns.Add("SCRIPTNAME"); dtResultSummary.Columns.Add("COMMENT"); dtResultSummary.Columns.Add("ACTION"); dtResultSummary.Columns.Add("ARGUMENT"); dtResultSummary.Columns.Add("RESULT"); dtResultSummary.Columns.Add("TIMETAKEN"); dtResultSummary.Columns.Add("MESSAGE"); string keyWord = ""; string stpexecute = ""; string stepFrom = ""; string comment = ""; string arg1 = ""; string arg2 = ""; string arg3 = ""; string arg4 = ""; string arg5 = ""; Helper.TestDataManagement driverData = new Helper.TestDataManagement(); string _epath = ConfigurationManager.AppSettings["logfile"]; string apppath = ConfigurationManager.AppSettings["apppath"]; string reportsSectionFile = ConfigurationManager.AppSettings["reportssectionfile"]; string strfile = ConfigurationManager.AppSettings["driverfile"]; Boolean returndriveFromExcel = true; Boolean _usewhite = Boolean.Parse(ConfigurationManager.AppSettings["usewhite"]); Boolean _detlog = Boolean.Parse(ConfigurationManager.AppSettings["Detaillog"]); //*************** 1. Launch Wellflo application ************************************ //WPF_App.WpfAction wpfaction = new WPF_App.WpfAction(); UIAutomation_App.UIAutomationAction uiautomation = new UIAutomation_App.UIAutomationAction(); uiautomation._Attempts = _attempt; uiautomation.UseWhite = _usewhite; uiautomation._eLogPtah = _epath; uiautomation._reportsPath = _reportsPath; uiautomation._reportsSectionPath = reportsSectionFile; uiautomation.UseDetaillog = _detlog; Helper.TestDataManagement testdataobj = new Helper.TestDataManagement(); Helper.LogManagement logg = new Helper.LogManagement(); WellFloUI.MSUIAutomation wellflocomui = new WellFloUI.MSUIAutomation(); uiautomation._testDataPath = _strPath; AutoItX3Lib.AutoItX3 autoit = new AutoItX3Lib.AutoItX3(); Helper.ReportsManagement rpt = new Helper.ReportsManagement(); driverData.GetTestData(excelfilePath, "Tmaster"); int pascount = 0; int failcount = 0; for (int i = 0; i < driverData.Structure.Rows.Count; i++) { System.Diagnostics.Stopwatch stopwatch3 = new System.Diagnostics.Stopwatch(); stopwatch3.Start(); DataRow dr = dtResultSummary.NewRow(); comment = driverData.Structure.Rows[i]["Comment"].ToString(); keyWord = driverData.Structure.Rows[i]["Keyword"].ToString(); stpexecute = driverData.Structure.Rows[i]["Execute"].ToString(); stepFrom = driverData.Structure.Rows[i]["StepFrom"].ToString(); arg1 = driverData.Structure.Rows[i]["arg1"].ToString(); arg2 = driverData.Structure.Rows[i]["arg2"].ToString(); arg3 = driverData.Structure.Rows[i]["arg3"].ToString(); arg4 = driverData.Structure.Rows[i]["arg4"].ToString(); arg5 = driverData.Structure.Rows[i]["arg5"].ToString(); dr["SCRIPTNAME"] = _scriptName; dr["SNO"] = (sNo + 1).ToString(); dr["ACTION"] = keyWord; if (comment == null) { dr["COMMENT"] = " "; } else { dr["COMMENT"] = comment; } if (arg1 == null) { dr["ARGUMENT"] = " "; } else { dr["ARGUMENT"] = arg1; } if (stpexecute.ToLower() == "y") { logg.CreateCustomLog(_epath, "Performing Keyword:=====>" + comment + "===================================="); switch (keyWord.ToLower()) { #region Generic keywords #region launchapplication case "launchapplication": { string repeat = new string('=', 50); logg.CreateCustomLog(_epath, repeat + " Launching Application " + arg1 + DateTime.Now.ToString() + repeat); try { if (stepFrom == "0") { if (GetOSArchitecture() == "32") { logg.CreateCustomLog(_epath, "Os is 32 bit OS "); arg1 = arg1.Replace("Program Files (x86)", "Program Files"); logg.CreateCustomLog(_epath, "app path is " + arg1); } else { logg.CreateCustomLog(_epath, "Os is 64 bit OS "); if (arg1.Contains("x86") == false) { arg1 = arg1.Replace("Program Files", "Program Files (x86)"); } logg.CreateCustomLog(_epath, "app path is " + arg1); } //we are using realtive path wrt test folder for launch if (arg1.Contains("\\") == false) { arg1 = Path.Combine(ConfigurationManager.AppSettings["testinputdata"], arg1); } #region OriginalLaunch if (File.Exists(arg1) == false) { Console.WriteLine("The Argument passed from excel script -arg1" + arg1 + "Does not exist..Please verifty if paths and configurations are correct"); return false; } System.Diagnostics.Process p = new System.Diagnostics.Process(); p.StartInfo.FileName = arg1; Console.WriteLine("Argument is " + arg1); p.Start(); int processId = p.Id; uiautomation._processId = processId; while (!p.MainWindowTitle.Contains(arg3)) { Console.WriteLine("Window Title----> {0}", p.MainWindowTitle); Thread.Sleep(10); p.Refresh(); } Console.WriteLine("End Window Title {0}", p.MainWindowTitle); #endregion OriginalLaunch int lastbackslashpos = arg1.LastIndexOf("\\") + 1; System.Console.WriteLine("lastbackslashpos: " + lastbackslashpos); int arg1Len = arg1.Length; System.Console.WriteLine("arg1 Length: " + arg1Len); int diff = arg1.Length - lastbackslashpos; System.Console.WriteLine("diff Length: " + diff); arg1 = arg1.Substring(lastbackslashpos, diff); if (arg1.Contains(".exe") == true) { arg1 = arg1.Replace(".exe", ""); } System.Console.WriteLine("Exe or Process name to attach is: " + arg1); if (arg2 == null || arg2 == "") //use Process name from arg1 itself no need to supply from excel { //White.Core.Application app = wpfaction.GetWPFApp(arg1); // ---> Launch the Application //uiautomation._application = app; } else //read arg2 from Script File { //White.Core.Application app = wpfaction.GetWPFApp(arg2); // ---> Launch the Application //uiautomation._application = app; } } else if (stepFrom == "1") { //White.Core.Application app = wpfaction.GetWPFApp(arg2); // ---> Launch the Application //uiautomation._application = app; //wpfaction._application = app; } else { logg.CreateCustomLog(_epath, "[Wraper]:Invalid stepfrom value"); } stopwatch3.Stop(); dr["RESULT"] = "Success"; dr["MESSAGE"] = "Completed"; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); repeat = new string('=', 50); logg.CreateCustomLog(_epath, repeat + " Application Launched " + DateTime.Now.ToString() + repeat); pascount++; } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in Keyword Launch:" + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated " + ex.Message; logg.CreateCustomLog(_epath, repeat + " Failed to Launch Application" + DateTime.Now.ToString() + repeat); failcount++; } break; } #endregion #region launchindirect case "launchindirect": { try { if (stepFrom == "0") { if (GetOSArchitecture() == "32") { logg.CreateCustomLog(_epath, "Os is 32 bit OS "); arg1 = arg1.Replace("Program Files (x86)", "Program Files"); logg.CreateCustomLog(_epath, "app path is " + arg1); } else { logg.CreateCustomLog(_epath, "Os is 64 bit OS "); if (arg1.Contains("x86") == false) { arg1 = arg1.Replace("Program Files", "Program Files (x86)"); } logg.CreateCustomLog(_epath, "app path is " + arg1); } #region New Launch System.Diagnostics.Process p = new System.Diagnostics.Process(); p.StartInfo.FileName = arg1; p.Start(); Process[] myprocess = Process.GetProcessesByName(arg2); while (myprocess.Length == 0) { logg.CreateCustomLog(_epath, "Launching Main Process "); myprocess = Process.GetProcessesByName(arg2); Thread.Sleep(1000); } logg.CreateCustomLog(_epath, "Launched: " + myprocess[0].ProcessName); Process actualProcess = myprocess[0]; while (!actualProcess.MainWindowTitle.Contains(arg3)) { Console.WriteLine("Window Title----> {0}", actualProcess.MainWindowTitle); Thread.Sleep(10); actualProcess.Refresh(); } Console.WriteLine("End Window Title {0}", actualProcess.MainWindowTitle); uiautomation._processId = actualProcess.Id; #endregion int lastbackslashpos = arg1.LastIndexOf("\\") + 1; System.Console.WriteLine("lastbackslashpos: " + lastbackslashpos); int arg1Len = arg1.Length; System.Console.WriteLine("arg1 Length: " + arg1Len); int diff = arg1.Length - lastbackslashpos; System.Console.WriteLine("diff Length: " + diff); arg1 = arg1.Substring(lastbackslashpos, diff); if (arg1.Contains(".exe") == true) { arg1 = arg1.Replace(".exe", ""); } System.Console.WriteLine("Exe or Process name to attach is: " + arg1); if (arg2 == null || arg2 == "") //use Process name from arg1 itself no need to supply from excel { //White.Core.Application app = wpfaction.GetWPFApp(arg1); // ---> Launch the Application //uiautomation._application = app; } else //read arg2 from Script File { //White.Core.Application app = wpfaction.GetWPFApp(arg2); // ---> Launch the Application //uiautomation._application = app; } } else if (stepFrom == "1") { //White.Core.Application app = wpfaction.GetWPFApp(arg2); // ---> Launch the Application //uiautomation._application = app; //uiautomation._processId = app.Process.Id; //wpfaction._application = app; } else { logg.CreateCustomLog(_epath, "[Wraper]:Invalid stepfrom value"); } stopwatch3.Stop(); dr["RESULT"] = "Success"; dr["MESSAGE"] = "Completed"; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in Keyword Launchindirect:" + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated " + ex.Message; } break; } #endregion #region closewindow case "closewindow": { try { Thread.Sleep(2000); SendKeys.SendWait("{ENTER}"); SendKeys.SendWait("{ENTER}"); SendKeys.SendWait("%{F4}"); SendKeys.SendWait("{ENTER}"); stopwatch3.Stop(); dr["RESULT"] = "Success"; dr["MESSAGE"] = "Completed"; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); pascount++; } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in keyword Function CloseWindow" + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); failcount++; } break; } #endregion #region inputformdata case "inputformdata": { string repeat = new string('=', 50); logg.CreateCustomLog(_epath, "Strpath value is :" + _strPath); logg.CreateCustomLog(_epath, repeat + " Adding Data from Excel Path:=" + _strPath + arg1 + " for test case " + arg2 + DateTime.Now.ToString() + repeat); try { uiautomation.AddData(_strPath + arg1, arg2); stopwatch3.Stop(); dr["RESULT"] = "Success"; dr["MESSAGE"] = "Completed"; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); pascount++; } catch (Exception ex) { failcount++; returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in keyword Function inputformdata" + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); } break; } #endregion #region comapredoc case "comparedoc": { try { TestDataManagement testData = new Helper.TestDataManagement(); testData.GetTestData(_strPath + arg1, "T1"); DataTable expectedData = testData.Data; int tableNumber = int.Parse(arg3); //DataTable actualData = verifyReport(_strPath + arg2, tableNumber); //DataTable ResultTable = CompareData(expectedData, actualData); //Helper.ReportsManagement rppt1 = new Helper.ReportsManagement(); //rppt1.ResultTable = ResultTable; //rppt1.ReportPath = arg5; //rppt1.GenerateReport(_strPath + arg4); dr["RESULT"] = "Success"; dr["MESSAGE"] = "Completed"; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); pascount++; } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in keyword Function inputformdata" + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); failcount++; } break; } #endregion #region verifyfileexistence case "verifyfileexistence": { try { string expectedData = _strPath + arg1; DataTable ResultTable = verifyFileExistence(expectedData); Helper.ReportsManagement rppt1 = new Helper.ReportsManagement(); rppt1.ResultTable = ResultTable; rppt1.ReportPath = arg5; rppt1.GenerateReport(_strPath + arg4); stopwatch3.Stop(); dr["RESULT"] = "Success"; dr["MESSAGE"] = "Completed"; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); pascount++; } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in keyword Function inputformdata" + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); failcount++; } break; } #endregion #region closewindowwithtitle case "closewindowwithtitle": { try { //uiautomation._globalWindow = wpfaction.GetWPFWindow(arg1); uiautomation.closeGlobalWindow(); Thread.Sleep(2000); stopwatch3.Stop(); dr["RESULT"] = "Success"; dr["MESSAGE"] = "Completed"; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); pascount++; } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in closewindowwithtitle" + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); failcount++; } break; } #endregion #region resetuiwindow case "resetuiwindow": { try { uiautomation.uiAutomationWindow = null; stopwatch3.Stop(); dr["RESULT"] = "Success"; dr["MESSAGE"] = "Completed"; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); pascount++; } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in resetuiwindow" + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); failcount++; } break; } #endregion #region verifydatatable case "verifydatatable": { try { uiautomation.VerifyData(_strPath + arg1, arg2); stopwatch3.Stop(); dr["RESULT"] = "Success"; dr["MESSAGE"] = "Completed"; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); pascount++; } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in verifydatatable" + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); failcount++; } break; } #endregion #region verifyformdata case "verifyformdata": { try { _finalReports = arg5; string repeat = new string('=', 50); logg.CreateCustomLog(_epath, arg1); logg.CreateCustomLog(_epath, arg2); logg.CreateCustomLog(_epath, arg3); logg.CreateCustomLog(_epath, arg4); logg.CreateCustomLog(_epath, arg5); logg.CreateCustomLog(_epath, "1-5 arguments"); logg.CreateCustomLog(_epath, repeat + "Verifying Data from Excel " + arg1 + "for test case " + arg2 + DateTime.Now.ToString() + repeat); uiautomation.verifyDataForm(_strPath + arg1, arg2, arg3, _strPath + arg4, arg5); stopwatch3.Stop(); dr["RESULT"] = "Success"; dr["MESSAGE"] = "Completed"; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); pascount++; } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in verifydatatable" + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); failcount++; } break; } #endregion #region compareXML case "comparexml": { try { _finalReports = arg4; arg3 = ConfigurationManager.AppSettings["testinputdata"] + arg3; //arr[0]; logg.CreateCustomLog(_epath, "Path used for comparexml keyword" + arg1); if (arg1.Trim().Length == 0 || arg2.Trim().Length == 0 || arg3.Trim().Length == 0 || arg4.Trim().Length == 0) logg.CreateCustomLog(_epath, "Need values for arg1,arg2,arg3 and arg4"); else { CompareXML(arg1, arg2, arg3, arg4, logg, _epath); stopwatch3.Stop(); dr["RESULT"] = "Success"; dr["MESSAGE"] = "Completed"; dr["TimeTaken"] = (string)stopwatch3.Elapsed.Seconds.ToString(); } } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in comparexml " + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; } break; } #endregion #region verifydataiepanetable case "verifydataiepanetable": { try { uiautomation.verifyDataIEPaneTable(_strPath + arg1, arg2, arg3, _strPath + arg4, arg5); dr["RESULT"] = "Success"; dr["MESSAGE"] = "Completed"; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); pascount++; } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "verifydataiepanetable" + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); failcount++; } break; } #endregion #region manualintervention case "manualintervention": { try { fn_BalloonToolTip(arg1, arg2); Console.WriteLine("Please Press Enter to proceed to next step"); Console.ReadLine(); stopwatch3.Stop(); dr["RESULT"] = "Success"; dr["MESSAGE"] = "Completed"; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); pascount++; } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in manualintervention" + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); failcount++; } break; } #endregion #region verifywpfdatagrid case "verifywpfdatagrid": { try { uiautomation.VerifyDataGridContent(_strPath + arg1, arg2, arg3, _strPath + arg4, arg5); dr["RESULT"] = "Success"; dr["MESSAGE"] = "Completed"; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); pascount++; } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in verifywpfdatagrid" + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); failcount++; } break; } #endregion #region verifydatagrid case "verifydatagrid": { try { uiautomation.VerifyDataGrid2Content(_strPath + arg1, arg2, arg3, _strPath + arg4, arg5); dr["RESULT"] = "Success"; dr["MESSAGE"] = "Completed"; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); pascount++; } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in verifydatagrid" + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); failcount++; } break; } #endregion #region verify_plotdata case "verify_plotdata": { try { verify_plotdata(arg1, arg2); dr["RESULT"] = "Success"; dr["MESSAGE"] = "Completed"; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); pascount++; } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in verify_plotdata" + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); failcount++; } break; } #endregion #region infraselectrows case "infraselectrows": { try { selectspecfedrows(Int32.Parse(arg1), Int32.Parse(arg2)); dr["RESULT"] = "Success"; dr["MESSAGE"] = "Completed"; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); pascount++; } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in infraselectrows" + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); failcount++; } break; } #endregion #region clickbuttonwindowtitle case "clickbuttonwindowtitle": { try { wellflocomui.GetAppWindow(arg1); wellflocomui.ClickButton(arg2); dr["RESULT"] = "Success"; dr["MESSAGE"] = "Completed"; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); pascount++; } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in clickbuttonwindowtitle" + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); failcount++; } break; } #endregion #region clickbuttonwindowautoid case "clickbuttonwindowautoid": { try { //SearchCriteria search = SearchCriteria.ByAutomationId(arg1); //Window wnd = wpfaction._application.GetWindow(search, White.Core.Factory.InitializeOption.NoCache); //var btn = wnd.Get<White.Core.UIItems.Button>(arg2); //btn.Click(); //dr["RESULT"] = "Success"; //dr["MESSAGE"] = "Completed"; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); //pascount++; } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in clickbuttonwindowautoid" + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); failcount++; } break; } #endregion #region clickbuttonchildwindowtitle case "clickbuttonchildwindowtitle": { try { specialApply(arg1, arg2, arg3); dr["RESULT"] = "Success"; dr["MESSAGE"] = "Completed"; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); pascount++; } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in clickbuttonchildwindowtitle" + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); failcount++; } break; } #endregion #region clickcordinates case "clickcordinates": { try { string repeat = new string('=', 50); logg.CreateCustomLog(_epath, repeat + " Clicking coordinates " + arg1 + ";" + arg2 + DateTime.Now.ToString() + repeat); AutoItX3Lib.AutoItX3 at1 = new AutoItX3Lib.AutoItX3(); int x1 = Convert.ToInt32(arg1); int y1 = Convert.ToInt32(arg2); at1.MouseClick("LEFT", x1, y1, 1); dr["RESULT"] = "Success"; dr["MESSAGE"] = "Completed"; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); pascount++; } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in clickcordinates" + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); failcount++; } break; } #endregion #region createoutputimage case "createoutputimage": { try { createOutputImage(arg1); dr["RESULT"] = "Success"; dr["MESSAGE"] = "Completed"; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); pascount++; } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in createoutputimage" + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); failcount++; } break; } #endregion #region clickcordinatesdbl case "clickcordinatesdbl": { try { AutoItX3Lib.AutoItX3 at1 = new AutoItX3Lib.AutoItX3(); int x1 = Convert.ToInt32(arg1); int y1 = Convert.ToInt32(arg2); at1.MouseClick("LEFT", x1, y1, 2); dr["RESULT"] = "Success"; dr["MESSAGE"] = "Completed"; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); pascount++; } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in clickcordinates" + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); failcount++; } break; } #endregion #region rightclick case "rightclick": { try { AutoItX3Lib.AutoItX3 at1 = new AutoItX3Lib.AutoItX3(); int x1 = Convert.ToInt32(arg1); int y1 = Convert.ToInt32(arg2); at1.MouseClick("RIGHT", x1, y1, 1); dr["RESULT"] = "Success"; dr["MESSAGE"] = "Completed"; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); pascount++; } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in rightclick" + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); failcount++; } break; } #endregion #region wait case "wait": { try { logg.CreateCustomLog(_epath, "Performing Keyword:===== Wait ===================================="); Console.WriteLine("Waiting in Driver script for " + arg1 + "seconds"); Thread.Sleep(Int32.Parse(arg1) * 1000); dr["RESULT"] = "Success"; dr["MESSAGE"] = "Completed"; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); pascount++; } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in wait" + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); failcount++; } break; } #endregion #region updatestructure case "updatestructure": { try { UpdateStructure(arg1, arg2, arg3, arg4, arg5); dr["RESULT"] = "Success"; dr["MESSAGE"] = "Completed"; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); pascount++; } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in updatestructure" + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); failcount++; } break; } #endregion #region setexpectednactualdata case "setexpectednactualdata": { try { testdataobj.ActualData.Clear(); testdataobj.ExpectedData.Clear(); testdataobj.GetTestData(arg1, arg2); testdataobj.ActualData = testdataobj.Data; testdataobj.ExpectedData = testdataobj.GetVerificationData(arg3, arg4); dr["RESULT"] = "Success"; dr["MESSAGE"] = "Completed"; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); pascount++; } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in setexpectednactualdata" + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); failcount++; } break; } #endregion #region comparecsv case "comparecsv": { try { testdataobj.CompareData(); logg.CreateCustomLog(_epath, "Compare Data Finished"); rpt.ResultTable = testdataobj.ResultTable; rpt.ReportPath = arg2; logg.CreateCustomLog(_epath, "Trying to create Report"); rpt.GenerateReport(_strPath + arg1); dr["RESULT"] = "Success"; dr["MESSAGE"] = "Completed"; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); pascount++; } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in comparecsv" + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); failcount++; } break; } #endregion #region upadtereportersheet case "upadtereportersheet": { try { testdataobj.UpdateReporterSheet(_strPath + arg1, "testcase", arg2); testdataobj.UpdateReporterSheet(_strPath + arg1, "section", arg3); testdataobj.UpdateReporterSheet(_strPath + arg1, "webtable", arg4); dr["RESULT"] = "Success"; dr["MESSAGE"] = "Completed"; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); pascount++; } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in upadtereportersheet" + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); failcount++; } break; } #endregion #region copydata case "copydata": { try { Excel.Application xlApp = new Excel.Application(); Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(_strPath + arg1); Excel._Worksheet xlWorksheet = (Excel._Worksheet)xlWorkbook.Sheets[1]; Excel.Range xlRange = xlWorksheet.UsedRange; xlRange.Copy(System.Type.Missing); dr["RESULT"] = "Success"; dr["MESSAGE"] = "Completed"; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); pascount++; } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in CopyData" + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); failcount++; } break; } #endregion #region verifywordfile case "verifywordfile": { try { worddocverification(arg1, arg2); dr["RESULT"] = "Success"; dr["MESSAGE"] = "Completed"; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); pascount++; } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in verifywordfile " + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); failcount++; } break; } #endregion #region writeingrid case "writeingrid": { try { writeGridContent(arg1, arg2); dr["RESULT"] = "Success"; dr["MESSAGE"] = "Completed"; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); pascount++; } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in writeingrid " + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); failcount++; } break; } #endregion #region Compare Excel case "compareexcel": { try { CompareExcel(arg1, arg2); dr["RESULT"] = "Success"; dr["MESSAGE"] = "Completed"; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); pascount++; } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in writeingrid " + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); failcount++; } break; } #endregion #region Lowis related keywords #region deletefile case "deletefile": { try { DeleteFile(arg1, logg, _epath); stopwatch3.Stop(); dr["RESULT"] = "Success"; dr["MESSAGE"] = "Completed"; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in DeleteFile " + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); } break; } #endregion #region deletefiles case "deletefiles": { try { testdataobj.GetTestData(_deleteFilesPath, ""); DataTable dtDelete = testdataobj.Data; for (int row = 0; i < dtDelete.Rows.Count; row++) { DeleteFile((string)dtDelete.Rows[row][0], logg, _epath); } stopwatch3.Stop(); dr["RESULT"] = "Success"; dr["MESSAGE"] = "Completed"; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in DeleteFiles " + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); } break; } #endregion #region searchgridrow case "searchgridrow": { try { SearchGridRow(arg1, arg2, arg3, uiautomation._processId); stopwatch3.Stop(); dr["RESULT"] = "Success"; dr["MESSAGE"] = "Completed"; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in searchgridrow " + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); } break; } #endregion #region addrowtodatagrid case "addrowtodatagrid": { try { AddRowToDataGrid(arg1, arg2, uiautomation._processId); stopwatch3.Stop(); dr["RESULT"] = "Success"; dr["MESSAGE"] = "Completed"; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in addrowtodatagrid " + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); } break; } #endregion #region clickmenus case "clickmenus": { try { ClickMenus(arg1, arg2, uiautomation._processId); stopwatch3.Stop(); dr["RESULT"] = "Success"; dr["MESSAGE"] = "Completed"; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in clickmenus " + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); } break; } #endregion #region clickmenus case "clickbeamdesign": { try { ClickBeamDesign(arg1, arg2, arg3, uiautomation._processId); stopwatch3.Stop(); dr["RESULT"] = "Success"; dr["MESSAGE"] = "Completed"; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in clickbeamdesign " + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); } break; } #endregion #region cleanupcstore case "cleanupcstore": { try { cleanupcstore(arg1); dr["RESULT"] = "Success"; dr["Message"] = "Completed"; } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in cleanupcstore " + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); } break; } #endregion #region menuiteam case "menuiteam": { try { menuiteam(arg1); dr["RESULT"] = "Sucess"; dr["Message"] = "Completed"; } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in menuiteam" + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); } break; } #endregion #region standardpump case "standardpump": { try { standardpump(arg1, arg2, arg3); dr["RESULT"] = "Sucess"; dr["Message"] = "Completed"; } catch (Exception ex) { returndriveFromExcel = false; logg.CreateCustomLog(_epath, "Error in standardpumpsave" + ex.Message.ToString()); dr["RESULT"] = "Failed"; dr["MESSAGE"] = "Terminated" + ex.Message; dr["TIMETAKEN"] = (string)stopwatch3.Elapsed.Seconds.ToString(); } break; } #endregion #endregion default: returndriveFromExcel = false; throw new Exception("Not a valid Keyword"); } dtResultSummary.Rows.Add(dr); sNo = sNo + 1; } else { // logg.CreateCustomLog(_epath, "[Wraper]:Not Executing the Keyword: -> " + keyWord); } if (returndriveFromExcel == false) { logg.CreateCustomLog(_epath, "*********************ScriptTermination ********************************"); logg.CreateCustomLog(_epath, "Script: " + excelfilePath + "was terminited due to above errors and host or application was also terminated"); break; } } GenerateReport(_resultsSummaryFile, dtResultSummary); if (File.Exists(_resultsFile) == false) { Console.WriteLine("Result File does not exist: " + _resultsFile); } else { DataTable dtResults = GetResultsData(_resultsFile, ""); DataRow[] success = dtResults.Select("Result= 'Pass'"); DataRow[] failed = dtResults.Select("Result='Fail'"); Console.WriteLine("Finished Test (Errors:" + failed.Length.ToString() + "," + " Warnings:" + failcount + ")"); } return returndriveFromExcel; } catch (Exception ex) { Console.WriteLine("Generic Error has occurred " + ex.Message); return false; } }
public void verifyInfragisticsTableFlat(string testDataFile, string testcase, string customcolumnfile, string resultFilePath) { try { Helper.ReportsManagement rppt1 = new Helper.ReportsManagement(); testData.ExpectedData.Clear(); testData.ActualData.Clear(); testData.Template.Clear(); testData.Data.Clear(); testData.GetVerificationData(testDataFile, testcase); testData.ActualData = GetActualDataInfragisticsTableFlat(testDataFile); testData.UpdateReporterSheet(customcolumnfile, "testcase", testcase); testData.CompareDataForm(); rppt1.ResultTable = testData.ResultTable; rppt1.ReportPath = resultFilePath; rppt1.GenerateReport(customcolumnfile); testData.ResultTable.Clear(); } catch (Exception ex) { System.Console.WriteLine("[verifyInfragisticsTableFlat]: Execption Message : " + ex.Message.ToString()); logTofile(_eLogPtah, "[verifyInfragisticsTableFlat] Line number : " + GetStacktrace(ex).ToString()); throw new Exception(ex.Message); } }
private static void CompareXML(string expectedXmlFilePath, string actualXmlPath, string reportTemplate, string reportPath, LogManagement logg, string logpath) { try { logg.CreateCustomLog(logpath, "Inside CompareXML"); TestDataManagement management = new TestDataManagement(); ReportsManagement management2 = new ReportsManagement(); management.ActualData.Clear(); management.ExpectedData.Clear(); logg.CreateCustomLog(logpath, "Cleared old data"); DataSet set = new DataSet(); DataSet set2 = new DataSet(); set.ReadXml(expectedXmlFilePath); logg.CreateCustomLog(logpath, "Loaded ExpectedXML"); set2.ReadXml(actualXmlPath); logg.CreateCustomLog(logpath, "Loaded actualXML"); management.ExpectedData = set.Tables[0]; management.ActualData = set2.Tables[0]; logg.CreateCustomLog(logpath, "Created Actual and Expected Data Sets"); management.CompareData(); logg.CreateCustomLog(logpath, "DataBinder Compared"); management2.ResultTable = management.ResultTable; Console.WriteLine(management.ResultTable.Rows.Count); management2.ReportPath = reportPath; management2.GenerateReport(reportTemplate); logg.CreateCustomLog(logpath, "Report Generated"); } catch (Exception exception) { throw new Exception("Error in function CompareXML" + exception.Message); } }
public void verifyDataForm(string testDataFile, string testcase, string section, string customcolumnfile, string resultFilePath) { try { Helper.ReportsManagement rppt1 = new Helper.ReportsManagement(); try { testData.ExpectedData.Clear(); } catch (Exception ex) { logTofile(_eLogPtah, "Error occured in Expected Data: " + ex.Message); } logTofile(_eLogPtah, "Cleared Expected Data"); try { testData.ActualData.Clear(); } catch (Exception ex) { logTofile(_eLogPtah, "Error occured in Actual Data: " + ex.Message); } logTofile(_eLogPtah, "Cleared Actual Data"); try { testData.Template.Clear(); } catch (Exception ex) { logTofile(_eLogPtah, "Error occured in template Data: " + ex.Message); } logTofile(_eLogPtah, "Cleared Template Data"); testData.GetVerificationDataForm(testDataFile, testcase); logTofile(_eLogPtah, "GetVerificationDataForm completed"); testData.ActualData = GetActualDataForm(testDataFile); logTofile(_eLogPtah, "GetActualDataForm completed"); testData.UpdateReporterSheet(customcolumnfile, "testcase", testcase); testData.UpdateReporterSheet(customcolumnfile, "section", section); testData.UpdateReporterSheet(customcolumnfile, "webtable", "NA"); logTofile(_eLogPtah, "Reporter sheet updated"); testData.CompareDataForm(); logTofile(_eLogPtah, "comparing data completed"); rppt1.ResultTable = testData.ResultTable; rppt1.ReportPath = resultFilePath; rppt1.GenerateReport(customcolumnfile); logTofile(_eLogPtah, "Report generated"); testData.ResultTable.Clear(); } catch (Exception ex) { System.Console.WriteLine("[verifyDataForm]:Execption Message : " + ex.Message.ToString()); logTofile(_eLogPtah, "[verifyDataForm] Line number : " + GetStacktrace(ex).ToString()); throw new Exception(ex.Message); } }