/// <summary> /// Executes Test Cases /// </summary> public void Execute(Dictionary <String, String> browserConfig, String testCaseId, String iterationId, Report.Iteration iteration, Dictionary <String, String> testData, Report.Engine reportEngine, string iterationTestCasename) { try { this.Driver = Util.GetDriver(browserConfig); this.Reporter = iteration; this.TestCaseId = testCaseId; this.TestDataId = iterationId; this.TestData = testData; this.resultsPath = reportEngine.ReportPath; this.IterationTestCaseName = iterationTestCasename; if (browserConfig["target"] == "local") { var wmi = new ManagementObjectSearcher("select * from Win32_OperatingSystem").Get().Cast <ManagementObject>().First(); this.Reporter.Browser.PlatformName = String.Format("{0} {1}", ((string)wmi["Caption"]).Trim(), (string)wmi["OSArchitecture"]); this.Reporter.Browser.PlatformVersion = ((string)wmi["Version"]); this.Reporter.Browser.BrowserName = Driver.Capabilities.BrowserName; this.Reporter.Browser.BrowserVersion = Driver.Capabilities.Version.Substring(0, 2); } else { this.Reporter.Browser.PlatformName = browserConfig.ContainsKey("os") ? browserConfig["os"] : browserConfig["device"]; this.Reporter.Browser.PlatformVersion = browserConfig.ContainsKey("os_version") ? browserConfig["os_version"] : browserConfig.ContainsKey("realMobile") ? "Real" : "Emulator"; this.Reporter.Browser.BrowserName = browserConfig.ContainsKey("browser") ? browserConfig["browser"] : "Safari"; this.Reporter.Browser.BrowserVersion = browserConfig.ContainsKey("browser_version") ? browserConfig["browser_version"].Substring(0, 2) : ""; } // Does Seed having anything? if (this.Reporter.Chapter.Steps.Count == 0) { this.Reporter.Chapters.RemoveAt(0); } this.Reporter.StartTime = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.Local, TimeZoneInfo.FindSystemTimeZoneById("India Standard Time")); ExecuteTestCase(); } catch (Exception ex) { this.Reporter.Chapter.Step.Action.IsSuccess = false; this.Reporter.Chapter.Step.Action.Extra = "Exception Message : " + ex.Message + "<br/>" + ex.InnerException + ex.StackTrace; if (!(ex.ToString().Contains("target window already closed") || ex.ToString().Contains("chrome not reachable") || ex.ToString().Contains("unexpected alert open") || (ex.ToString().Contains("timed out after 60 seconds.")))) { // If current iteration is a failure, get screenshot if (!Reporter.IsSuccess) { ITakesScreenshot iTakeScreenshot = Driver; this.Reporter.Screenshot = iTakeScreenshot.GetScreenshot().AsBase64EncodedString; } } } finally { this.Reporter.IsCompleted = true; // If current iteration is a failure, get screenshot this.Reporter.EndTime = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.Local, TimeZoneInfo.FindSystemTimeZoneById("India Standard Time")); lock (reportEngine) { reportEngine.PublishIteration(this.Reporter); reportEngine.Summarize(false); } Driver.Quit(); } }