Example #1
0
 public async Task GlobalSetup()
 {
     ExecutionEnvironment executionEnvironment = new ExecutionEnvironment()
     {
     };
     await WebDriverHelper.EnsureDriverAsync(executionEnvironment);
 }
Example #2
0
        public static async Task <string> ExecuteAsync(this Test test, ExecutionEnvironment executionEnvironment)
        {
            test.Title             = executionEnvironment.Title;
            test.Measure.StartDate = DateTime.Now;
            _log_.Trace($"Begin Executing test {test.Name} | {test.Measure.StartDate}");
            string     sessionId     = string.Empty;
            IWebDriver testWebDriver = null;

            try
            {
                foreach (Step step in test.Steps)
                {
                    if (!string.IsNullOrEmpty(sessionId))
                    {
                        step.SessionId = sessionId;
                    }
                    else
                    {
                        if (executionEnvironment.GridEnabled == false)
                        {
                            await WebDriverHelper.EnsureDriverAsync(executionEnvironment);
                        }
                    }

                    step.Execute(ref testWebDriver, executionEnvironment);
                    if (sessionId != step.SessionId)
                    {
                        sessionId = step.SessionId;
                    }
                }
                test.Failed = false;
            }
            catch (Exception ex)
            {
                test.Failed     = true;
                test.StackTrace = $"{test.Name} : {ex.Message}";
            }
            finally
            {
                test.Measure.EndDate = DateTime.Now;
                if (testWebDriver != null)
                {
                    testWebDriver.Close();
                    testWebDriver.Quit();
                }
            }

            _log_.Trace($"End Executing test {test.Name} | {test.Measure.StartDate} - {test.Measure.EndDate}");
            return(sessionId);
        }