Esempio n. 1
0
 /// <summary>
 ///     Keep driver properties
 /// </summary>
 /// <param name="key"></param>
 /// <param name="properties"></param>
 public void SetDriverProperties(string key, DriverProperties properties)
 {
     _driverProperties.Add(key, properties);
 }
Esempio n. 2
0
        /// <summary>
        ///     create webdriver by properties,  driver key = "default" if not set
        /// </summary>
        public static void CreateDriver(DriverProperties pros, string key = "default")
        {
            DriverManager driverManager = null;

            switch (pros.GetDriverType())
            {
            case DriverType.Chrome:
                driverManager = new ChromeBrowser();
                break;

            case DriverType.Firefox:
                driverManager = new FireFoxBrowser();
                break;

            case DriverType.IE:
                driverManager = new IEBrowser();
                break;

            case DriverType.IOSApp:
                driverManager = new IOSAppDriver();
                break;

            case DriverType.IOSWeb:
                driverManager = new IOSWebDriver();
                break;

            case DriverType.AndroidApp:
                driverManager = new AndroidAppDriver();
                break;

            case DriverType.AndroidWeb:
                driverManager = new AndroidWebDriver();
                break;

            case DriverType.Edge:
                break;

            case DriverType.Safari:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            if (driverManager != null)
            {
                driverManager.SetDriverProperties(key, pros);
                driverManager.CreateDriver(key);
                if (_DRIVER.Value == null)
                {
                    _DRIVER.Value = driverManager;
                }
                else
                {
                    _DRIVER.Value.SetDriverProperties(key, pros);
                    _DRIVER.Value.SetWebDriver(key, driverManager.GetWebDriver(key));
                }

                var driverKey = new Key {
                    Name = key
                };
                _DRIVER_KEY.Value = driverKey;
            }
            else
            {
                throw new Exception("Cannot create web driver");
            }
        }