public BaseExecutionClass(TestCase currentTestCase) { dataHelper = TestSetUp.GetDataHelper(currentTestCase); Driver driverClass = new Driver(); driver = driverClass.GetWebDriver(currentTestCase); report = new Report(currentTestCase, driver); report.Driver = this.driver; }
public void ExecuteTestCases(String ClienURL) { bool exceptionOccured = false; RunManager.TestCaseCount = ExecutionSession.lstTestCase.Count; IRunTestCases runTestCases = TestSetUp.GetRunTestCase(); QCHelper qcHelper = null; if (HelperClass.QCUpdateResults) { qcHelper = new QCHelper(); } foreach (TestCase testCase in ExecutionSession.lstTestCase) { try { Console.WriteLine(testCase.TestCaseName + " Called"); runTestCases.CurrentTestCase = testCase; runTestCases.RunTestCase(); if (HelperClass.QCUpdateResults) { qcHelper.UploadResults(testCase); } } catch (Exception ex) { exceptionOccured = true; Logger.Log(ex.ToString()); } RunManager.Progresscount++; TestcaseProgressBar(RunManager.Progresscount, RunManager.TestCaseCount); } //if (!exceptionOccured) //{ // try // { // SummaryReport report = new SummaryReport(); // report.GenerateSummaryReport(); // TestSetUp.AddFailedTCToExcel(); // } // catch (Exception ex) // { // Logger.Log(ex.ToString()); // } //} }
public void ExecuteMultipleBrowsers() { List <TestCase> lstRunTC; Report rptTCMultiBrowser; DateTime startTime; QCHelper qcHelper = null; foreach (TestCase testCase in ExecutionSession.lstTestCase) { lstRunTC = ExecutionSession.lstAllBrowsersTC.Where(browserTC => browserTC.TestCaseName == testCase.TestCaseName).ToList(); IRunTestCases runTestCases; List <ThreadClass> lstThreads = new List <ThreadClass>(); ThreadClass storeThread; int count = lstRunTC.Count; int threadCnt = 1; startTime = DateTime.Now; foreach (TestCase currentTestCase in lstRunTC) { runTestCases = TestSetUp.GetRunTestCase(); runTestCases.CurrentTestCase = currentTestCase; Thread runThread = new Thread(runTestCases.RunTestCase); runThread.Name = "Thread" + threadCnt; storeThread = new ThreadClass(); storeThread.ThreadName = runThread.Name; storeThread.currentThread = runThread; lstThreads.Add(storeThread); runThread.Start(); if (currentTestCase.Browser == Browser.FireFox) { Thread.Sleep(8000); } threadCnt++; } while (lstThreads.Any(thread => thread.currentThread.IsAlive)) { } DateTime endTime = DateTime.Now; TimeSpan timeTaken = endTime.Subtract(startTime); string executionTime = timeTaken.Minutes + " mins and " + timeTaken.Seconds + " secs"; rptTCMultiBrowser = new Report(); rptTCMultiBrowser.GenerateMultiBrowserDetailedReport(lstRunTC, timeTaken); try { if (HelperClass.QCUpdateResults) { qcHelper = new QCHelper(); qcHelper.UploadResults(testCase); } } catch (Exception ex) { Logger.Log(ex.ToString()); } } try { SummaryReport report = new SummaryReport(); report.GenerateSummaryReport(); TestSetUp.AddFailedTCToExcel(); } catch (Exception ex) { Logger.Log(ex.ToString()); } }
// public static string stateName = string.Empty; // public static string cityName = string.Empty; public void RunTestCases() { ExecutionSession.startTime = DateTime.Now; bool exceptionOccured = false; try { TestSetUp.InitializeSetUp(); //SendStartMail(ExecutionSession.dictCommonData["Environment"]); //Environment.Exit(0); } catch (Exception ex) { Console.WriteLine("Error occured during Test Setup. Please look into logs for more details."); Logger.Log(ex.ToString()); Environment.Exit(0); } try { ExecutionSession.lstExecutedTestCases = new List <ExecutedTestCase>(); ExecutionSession.lstErrorsteps = new List <ErrorSteps>(); foreach (clientList ClientList in ExecutionSession.lstClient) { if (ClientProgresscount != 0) { ProgressBar(ClientProgresscount, ClientCount); } ExecutionSession.dictCommonData.Clear(); ExecutionSession.dictCommonData.Add("Environment", ClientList.EnvironmentName); ExecutionSession.dictCommonData.Add("EnvironmentUrl", ClientList.clientUrl); if (!HelperClass.runAllBrowsers && !HelperClass.runMultipleBrowsers && !HelperClass.runMultipleThreads) { ExecuteTestCases(ClientList.clientUrl); } else if (HelperClass.runAllBrowsers || HelperClass.runMultipleBrowsers) { ExecuteMultipleBrowsers(); } else if (HelperClass.runMultipleThreads) { ExecuteMultipleTestCases(); } Progresscount = 0; ClientProgresscount++; //Thread.Sleep(2000); Console.Clear(); if (ClientProgresscount == ClientCount) { ProgressBar(ClientProgresscount, ClientCount); } } } catch (Exception e) { exceptionOccured = true; } if (!exceptionOccured) { try { SummaryReport report = new SummaryReport(); report.GenerateSummaryReport(); TestSetUp.AddFailedTCToExcel(); // SendEndMail(ExecutionSession.dictCommonData["Environment"]); } catch (Exception ex) { Logger.Log(ex.ToString()); } } if (HelperClass.sendEmail) { QCHelper qcHelper = new QCHelper(); qcHelper.SendEmail(); } Driver.QuitDriver(Driver.driver); //HTMLChartSummaryReport htmlChartSummaryReport = new HTMLChartSummaryReport(); //htmlChartSummaryReport.generateSummaryReport(); //System.Diagnostics.Process.Start(HelperClass.reportRunPath + "\\" + "SummaryReport" + ".html"); }
public void ExecuteMultipleTestCases() { IRunTestCases runTestCases = TestSetUp.GetRunTestCase(); List <ThreadClass> lstThreads = new List <ThreadClass>(); ThreadClass storeThread; int count = ExecutionSession.lstTestCase.Count; int runTestCaseCount = 0; if (ExecutionSession.lstTestCase.Count < HelperClass.runNoofThreads) { runTestCaseCount = ExecutionSession.lstTestCase.Count; } else { runTestCaseCount = HelperClass.runNoofThreads; } int threadCnt = 0; while (threadCnt < count) { if (threadCnt == 0) { for (int iLp = 1; iLp <= runTestCaseCount; iLp++) { TestCase testCase = ExecutionSession.lstTestCase[threadCnt]; runTestCases.CurrentTestCase = testCase; Thread runThread = new Thread(runTestCases.RunTestCase); runThread.Name = "Thread" + iLp; storeThread = new ThreadClass(); storeThread.ThreadName = runThread.Name; storeThread.currentThread = runThread; lstThreads.Add(storeThread); runThread.Start(); threadCnt++; Console.WriteLine("Threads executed is : " + threadCnt); Thread.Sleep(700); } } else { foreach (ThreadClass currentThread in lstThreads) { if (currentThread.currentThread.IsAlive == false) { if (threadCnt < count) { Console.WriteLine("Thread " + currentThread.ThreadName + " is alive :" + currentThread.currentThread.IsAlive); runTestCases = TestSetUp.GetRunTestCase(); TestCase testCase = ExecutionSession.lstTestCase[threadCnt]; runTestCases.CurrentTestCase = testCase; Thread runThread = new Thread(runTestCases.RunTestCase); runThread.Name = currentThread.ThreadName; currentThread.currentThread = runThread; runThread.Start(); threadCnt++; Console.WriteLine("Threads executed is : " + threadCnt); Thread.Sleep(700); } } } } } while (lstThreads.Any(thread => thread.currentThread.IsAlive)) { } try { SummaryReport report = new SummaryReport(); report.GenerateSummaryReport(); TestSetUp.AddFailedTCToExcel(); } catch (Exception ex) { Logger.Log(ex.ToString()); } }