Exemplo n.º 1
0
        public async Task LoadDriverAsync(IDriverConfiguration driverConfiguration, IEnumerable <DriverInfo> driverInfos, Action <DriverInstance> driverLoaded)
        {
            var driverInfo = driverInfos.FirstOrDefault(x => x.Name == driverConfiguration.Name);

            if (driverInfo == null)
            {
                Log.Warn($"Driver '{driverConfiguration.Name}' not found");

                return;
            }

            var driverInstance = _classFactory.Create(driverInfo.DriverType);

            switch (driverInstance)
            {
            case null:
                Log.Warn($"Driver '{driverConfiguration.Name}' could not be created");
                return;

            case IDriver driver:
                Log.Info($"Driver '{driverConfiguration.Name} {driverInfo.Version}' loaded");
                await driver.InitAsync().ConfigureAwait(false);

                driverLoaded(new DriverInstance(driver, driverInfo));
                return;

            default:
                Log.Warn($"Driver '{driverInstance.GetType().FullName}' must implement IDriver interface");
                return;
            }
        }
Exemplo n.º 2
0
        public static TValue GetValue <TValue>(this IDriverConfiguration configuration, string key, TValue defaultValue)
        {
            var value = configuration.GetSection(key).Value;

            if (value != null)
            {
                return((TValue)value);
            }
            return(defaultValue);
        }
        public static IWebDriver GetDriver(IDriverConfiguration configuration)
        {
            Uri        seleniumServer = new Uri(configuration.SeleniumServerAddress);
            Browser    browser        = Browser.Chrome; //= configuration.Browser.AsEnum<Browser>();
            IWebDriver driver         = RemoteWebDriverFactory.GetCapabilityFor(browser, seleniumServer);

            driver.Manage().Window.Maximize();
            driver.Manage().Cookies.DeleteAllCookies();



            return(driver);
        }
Exemplo n.º 4
0
 public static TValue GetValue <TValue>(this IDriverConfiguration configuration, string key)
 {
     return(GetValue <TValue>(configuration, key, default));
 }
Exemplo n.º 5
0
 public static object GetValue(this IDriverConfiguration configuration, string key, object defaultValue)
 {
     return(configuration.GetSection(key).Value ?? defaultValue);
 }
Exemplo n.º 6
0
 public static object GetValue(this IDriverConfiguration configuration, string key)
 {
     return(GetValue(configuration, key, null));
 }