public void SetupRunSourceAndBrowser(RunSourceOptions runSource, BrowserOptions browser, CIOptions ci)
        {
            Uri    hubUri       = null;
            string driverPath   = null;
            var    capabilities = new DesiredCapabilities();

            capabilities.SetCapability("username", "glebabee");
            capabilities.SetCapability("accessKey", "ea9def77-f807-4247-9cfd-bb98c26d45b4");

            switch (runSource)
            {
            case RunSourceOptions.Local:
                driverPath = GetDriverFolder();
                break;

            case RunSourceOptions.SauceLabs:
                hubUri = new Uri("https://ondemand.saucelabs.com/wd/hub");
                break;

            case RunSourceOptions.SeleniumGrid:
                switch (ci)
                {
                case CIOptions.NA:
                    hubUri = new Uri("http://10.10.22.138:4445/wd/hub");
                    break;

                case CIOptions.Jenkins:
                    hubUri = new Uri("http://10.10.22.138:4444/wd/hub");
                    break;

                case CIOptions.TeamCity:
                    hubUri = new Uri("http://10.10.22.138:4445/wd/hub");
                    break;
                }
                break;
            }

            switch (browser)
            {
            case BrowserOptions.Chrome:
                var chromeOptions = new ChromeOptions();
                chromeOptions.AddArgument("--start-maximized");
                switch (runSource)
                {
                case RunSourceOptions.Local:
                    Driver = new ChromeDriver(driverPath, chromeOptions);
                    break;

                case RunSourceOptions.SauceLabs:
                    capabilities.SetCapability("browserName", "Chrome");
                    capabilities.SetCapability("version", "40.0");
                    capabilities.SetCapability("platform", "Linux");
                    Driver = new RemoteWebDriver(hubUri, capabilities);
                    break;

                case RunSourceOptions.SeleniumGrid:
                    Driver = new RemoteWebDriver(hubUri, chromeOptions);
                    break;
                }
                break;

            case BrowserOptions.FireFox:
                var fireFoxOptions = new FirefoxOptions();
                switch (runSource)
                {
                case RunSourceOptions.Local:
                    Driver = new FirefoxDriver(driverPath, fireFoxOptions);
                    Driver.Manage().Window.Maximize();
                    break;

                case RunSourceOptions.SauceLabs:
                    capabilities.SetCapability("browserName", "Firefox");
                    capabilities.SetCapability("version", "39.0");
                    capabilities.SetCapability("platform", "Windows 8.1");
                    Driver = new RemoteWebDriver(hubUri, capabilities);
                    break;

                case RunSourceOptions.SeleniumGrid:
                    Driver = new RemoteWebDriver(hubUri, fireFoxOptions);
                    Driver.Manage().Window.Maximize();
                    break;
                }
                break;

            case BrowserOptions.IE:
                var ieOptions = new InternetExplorerOptions();
                switch (runSource)
                {
                case RunSourceOptions.Local:
                    Driver = new InternetExplorerDriver(driverPath, ieOptions);
                    Driver.Manage().Window.Maximize();
                    break;

                case RunSourceOptions.SauceLabs:
                    capabilities.SetCapability("browserName", "InternetExplorer");
                    capabilities.SetCapability("version", "11");
                    capabilities.SetCapability("platform", "Windows 10");
                    Driver = new RemoteWebDriver(hubUri, capabilities);
                    break;

                case RunSourceOptions.SeleniumGrid:
                    Driver = new RemoteWebDriver(hubUri, ieOptions);
                    break;
                }
                break;

            case BrowserOptions.Edge:
                var edgeOptions = new EdgeOptions();
                switch (runSource)
                {
                case RunSourceOptions.Local:
                    Driver = new EdgeDriver(driverPath, edgeOptions);
                    Driver.Manage().Window.Maximize();
                    break;

                case RunSourceOptions.SauceLabs:
                    capabilities.SetCapability("browserName", "MicrosoftEdge");
                    capabilities.SetCapability("version", "16.16299");
                    capabilities.SetCapability("platform", "Windows 10");
                    Driver = new RemoteWebDriver(hubUri, capabilities);
                    break;

                case RunSourceOptions.SeleniumGrid:
                    Driver = new RemoteWebDriver(hubUri, edgeOptions);
                    break;
                }
                break;
            }
        }
        public AllureConfig CreateConfig(BrowserOptions browser, CIOptions ci)
        {
            var    currentAssembly = Assembly.GetCallingAssembly().GetName().Name;
            string directory       = null;

            switch (ci)
            {
            case CIOptions.NA:
                directory = @"C:/Users/GlebGusev/Desktop/AutomationTraining/TestProject/TestResults/" + currentAssembly + "_results";
                break;

            case CIOptions.Jenkins:
                directory = @"C:/Program Files (x86)/Jenkins/workspace/Run Nunit/TestProject/TestResults/" + currentAssembly + "_results";
                break;

            case CIOptions.TeamCity:
                directory = "C:/TeamCity/buildAgent/work/357d8625a94da553/TestProject/TestResults/" + currentAssembly + "_results";
                break;
            }
            return(new AllureConfig
            {
                Allure = new Allure
                {
                    AllowEmptySuites = true,
                    AllowLocalHistoryTrend = true,
                    EnableParameters = false,
                    Directory = directory
                },
                Categories = new List <Categories>
                {
                    new Categories {
                        Name = "Problems with locators", TraceRegex = ".*NoSuchElementException.*"
                    },
                    new Categories {
                        Name = "Problems with DOM", TraceRegex = ".*StaleElementReferenceException.*"
                    },
                    new Categories {
                        Name = "Problems with timeout", MessageRegex = ".*Timed out.*", TraceRegex = ".*"
                    },
                    new Categories {
                        Name = "Broken tests", MatchedStatuses = new List <string> {
                            "broken"
                        }
                    },
                    new Categories {
                        Name = "Ignored tests", MatchedStatuses = new List <string> {
                            "skipped"
                        }
                    },
                    new Categories {
                        Name = "Defected tests", MatchedStatuses = new List <string> {
                            "failed"
                        }
                    },
                    new Categories {
                        Name = "Passed tests", MatchedStatuses = new List <string> {
                            "passed"
                        }
                    }
                },
                Environment = new Environment
                {
                    Browser = browser.ToString(),
                    RunTime = new RunTime
                    {
                        RunDateTIme = DateTime.Now,
                        OS = System.Environment.OSVersion.VersionString,
                        AllureVersion = "Allure.Commons.AllureLifecycle.AllureVersion"
                    }
                }
            });
        }