private TestResult HandleTest(WorkItem workItem) { TestResult testResult = new TestResult(); ITestable testable = null; List <string> log = new List <string>(); try { log.Add("Test on " + _nodename); /**1: Load Testclass **/ Console.WriteLine(@"Testing {0} {1} ({2}/{3})", workItem.Testcase.Name, workItem.Browser.Name, workItem.Testsystem.Name, workItem.Language.Languagecode); testable = LoadTestable(workItem); if (testable == null) { return new TestResult { TestState = TestState.NotAvailable } } ; /**2: Wait for branch get ready **/ WaitOnWebExceptions(workItem); /**3: Prepare Test **/ Browser browser = new Browser() { Browserstring = workItem.Browser.Browserstring, Versionsstring = workItem.Browser.Versionsstring }; testable.SetupTest(WebDriverInitStrategy.SeleniumLocal, browser, workItem.Testsystem.Url, workItem.Language.Languagecode); /**4: Run Test **/ testable.Test(); testResult.TestState = TestState.Success; } catch (NotSupportedException notSupportedException) { Error error = CreateErrorFromException(notSupportedException); testResult.TestState = TestState.NotSupported; testResult.Error = error; } catch (TaskCanceledException taskCanceledException) { Error error = CreateErrorFromException(taskCanceledException); testResult.TestState = TestState.Canceled; testResult.Error = error; } catch (Exception exception) { ServerErrorModel serverException = null; try { if (testable != null) { serverException = testable.CheckForServerError(); } } catch { //Error catching serverException } Error error = CreateErrorFromException(exception); if (serverException != null) { error.Type = serverException.Type; error.Message = serverException.Message; error.InnerException = serverException.InnerException; //objError.StackTrace = serverException.StackTrace; Keep error stacktrace. } testResult.TestState = TestState.Error; testResult.Error = error; if (testable != null) { testResult.Screenshot = testable.SaveScreenshot(""); } } finally { if (testable != null) { testable.TeardownTest(); log.AddRange(testable.GetLogLastTime()); } testResult.Log = log; } return(testResult); }