Esempio n. 1
0
 public WebDriver(DriverTypes driverType, string rootUrl, string appPath = "/")
 {
     DriverType = driverType;
     RootUrl = rootUrl;
     AppPath = appPath;
     SetupDriver();
 }
        private IWebDriver GetDriver(DriverTypes type)
        {
            IWebDriver driver = null;

            switch (type)
            {
            case DriverTypes.IE:
                driver = new InternetExplorerDriver(
                    new InternetExplorerOptions
                {
                    UnexpectedAlertBehavior = InternetExplorerUnexpectedAlertBehavior.Default,
                    EnableNativeEvents      = true,
                    //ForceCreateProcessApi = true,
                    //BrowserCommandLineArguments = "-private",
                    EnsureCleanSession = true
                });
                driver = new NgWebDriver(driver);
                break;

            case DriverTypes.Chrome:
                ChromeOptions options = new ChromeOptions();
                options.AddArgument("--disable-plugins");
                driver = new ChromeDriver(options);
                driver = new NgWebDriver(driver);
                break;
            }
            ((NgWebDriver)driver).IgnoreSynchronization = true;
            return(driver);
        }
        public static void Init()
        {
            SystemHelper sh = new SystemHelper();

            foreach (var dtk in _apiMap.Values.Select(t => $"{t.Name} Drivers"))
            {
                tlog.LogMessage("DriverLoader", $"Loading/Creating node for Ascom {dtk}");
                DriverTypeNode dn = sh.SubNode <DriverTypeNode>(sh.Ascom.ProfileNodeId, $"{dtk}", true);
                if (dn == null)
                {
                    tlog.LogMessage("DriverLoader", $"Failed to access Ascom {dtk}");
                    throw new DriverException("Driver loader initialization failed");
                }
                tlog.LogMessage("DriverLoader", $"Got handle to Ascom {dtk} [{dn.ProfileNodeId}]");
            }

            tlog.LogMessage("AscomDriverLoader", $"Driver Root: {DriverRoot}");
            tlog.LogMessage("AscomDriverLoader", $"Loading assemblies...");
            LoadAssemblies();
            tlog.LogMessage("AscomDriverLoader", $"{Assemblies.Count()} assemblies loaded");
            foreach (var a in Assemblies)
            {
                Version aver = a?.GetName().Version;
                tlog.LogMessage("AscomDriverLoader", $"\t {a.FullName} v{aver.Major}.{aver.Minor}.{aver.MajorRevision}.{aver.MinorRevision}");
            }
            tlog.LogMessage("AscomDriverLoader", $"Registering drivers...");
            RegisterDrivers();
            tlog.LogMessage("AscomDriverLoader", $"{DriverTypes.Count()} drivers loaded");
            foreach (var dt in DriverTypes)
            {
                tlog.LogMessage("AscomDriverLoader", $"\t {dt.FullName}");
            }
        }
Esempio n. 4
0
        public static IWebDriver GetDriver(DriverTypes driver)
        {
            Dictionary <DriverTypes, IDriver> drivers = new Dictionary <DriverTypes, IDriver>();

            drivers.Add(DriverTypes.CHROME, new Chrome());
            drivers.Add(DriverTypes.FIREFOX, new Firefox());
            return(drivers[driver].InitDriver());
        }
Esempio n. 5
0
 public SeleniumTestsForAppulate(DriverTypes type)
 {
     _driver = DriverInitHelper.CreateDriver(type);
     _driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
     _driver.Manage().Window.Maximize();
     _mainSteps        = new MainSteps(_driver);
     _uploadImageSteps = new UploadImageSteps(_driver);
     _fillingNameSteps = new FillingNameSteps(_driver);
 }
Esempio n. 6
0
 public static void Initialize(DriverTypes driverType)
 {
     //SessConfiguration.AppHost = BaseUrl;
     SessConfiguration.Browser       = browsersToBeTested[driverType];
     SessConfiguration.Timeout       = TimeSpan.FromSeconds(Constants.MaxTimeOut);
     SessConfiguration.RetryInterval = TimeSpan.FromSeconds(0.5);
     Instance = new BrowserSession(SessConfiguration);
     Instance.MaximiseWindow();
     //((RemoteWebDriver)Instance.Native).Manage().Window.Maximize();
 }
Esempio n. 7
0
        public void Init(DriverTypes driver, ScreenSizes windowSize)
        {
            Driver = GetDriver(driver);

            Driver.Manage().Window.Size =
                new System.Drawing.Size(
                    EnumsHelper.GetWidth(windowSize),
                    EnumsHelper.GetHeight(windowSize));
            var l  = Driver.Manage().Window.Size.Height;
            var fl = Driver.Manage().Window.Size.Width;
        }
Esempio n. 8
0
        public string RegisterDriver(DriverTypes driverType)
        {
            switch (RunType)
            {
            case RunTypes.Local:
                return(RegisterLocalDriver(driverType));

            case RunTypes.Remote:
                return(RegisterRemoteDriver(driverType));
            }
            throw new Exception(); // TODO
        }
Esempio n. 9
0
        private string RegisterRemoteDriver(DriverTypes driverType)
        {
            var capabilities = new DesiredCapabilities(new Dictionary <string, object>
            {
                { "browserName", _driverNamesDictionary[driverType] },
                { "version", Empty },
                { "javaScript", true }
            });

            return(RegisterDriver("Remote_" + _driverNamesDictionary[driverType],
                                  () => new RemoteWebDriver(new Uri(Default.remote_url), capabilities)));
        }
Esempio n. 10
0
        public void InitializeDriver()
        {
            DriverTypes driverType   = (DriverTypes)System.Enum.Parse(typeof(DriverTypes), ConfigurationManager.AppSettings["Browser"].ToString());
            int         implicitWait = int.Parse(ConfigurationManager.AppSettings["ImplicitTime"].ToString());
            int         explicitWait = int.Parse(ConfigurationManager.AppSettings["ExplicitTime"].ToString());

            webDriver = DriverFactory.GetDriver(driverType);
            webDriver.Manage().Window.Maximize();

            webDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(implicitWait);
            webDriverWait = new WebDriverWait(webDriver, TimeSpan.FromSeconds(explicitWait));
        }
Esempio n. 11
0
        private IWebDriver GetDriver(DriverTypes driver)
        {
            switch (driver)
            {
            case DriverTypes.Chrome: return(new ChromeDriver(@"C:\Users\ya\Source\Repos\ScreenshotTesting\Steps\bin\Debug"));

            case DriverTypes.FireFox: return(new FirefoxDriver());

            case DriverTypes.IE: return(new InternetExplorerDriver());

            case DriverTypes.Opera: return(new OperaDriver());

            default: return(null);
            }
        }
Esempio n. 12
0
        //TODO
        private String RegisterLocalDriver(DriverTypes driverType)
        {
            var driverName = _driversDictionary[driverType];

            switch (driverType)
            {
            case DriverTypes.Chrome:
                return(RegisterDriver(driverName, () => new ChromeDriver(DriverPath)));

            case DriverTypes.Firefox:
                return(RegisterDriver(driverName, () => new FirefoxDriver()));

            case DriverTypes.IE:
                return(RegisterDriver(driverName, () => new InternetExplorerDriver(DriverPath)));
            }
            throw new Exception(); // TODO
        }
Esempio n. 13
0
        public static IWebDriver CreateDriver(DriverTypes type)
        {
            string pathToDrivers = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\..\..\");

            switch (type)
            {
            case (DriverTypes.Chrome):
                return(new ChromeDriver(pathToDrivers));

            case (DriverTypes.Edge):
                return(new EdgeDriver(pathToDrivers));

            case (DriverTypes.Explorer):
                return(new InternetExplorerDriver(InternetExplorerDriverService.CreateDefaultService(pathToDrivers)));

            default:
                throw new ArgumentException("Incorrect type.");
            }
        }
Esempio n. 14
0
        public SegmentFactory GetFactory(DriverTypes driverType)
        {
            SegmentFactory newFactory = null;

            string driverTypeDescription = EnumUtils.stringValueOf(driverType);

            // Using custom attributes on the defined HL7 Segment Factory classes, we
            // can find the proper class to create an instance of. Doing it this
            // way, this factory class does not have to be updated each time a
            // new driver type is added.
            var types = from a in AppDomain.CurrentDomain.GetAssemblies()
                        from t in a.GetTypes()
                        where t.IsDefined(typeof(HL7SegmentFactoryAttribute), true)
                        select t;

            foreach (Type t in types)
            {
                var attributes = t.GetCustomAttributes(typeof(HL7SegmentFactoryAttribute), true);
                foreach (HL7SegmentFactoryAttribute a in attributes)
                {
                    if (a.DriverType == driverTypeDescription)
                    {
                        object[] constructorArgs =
                        {
                            _delimiters
                        };
                        object obj = Activator.CreateInstance(t, constructorArgs);

                        newFactory = (SegmentFactory)obj;
                        break;
                    }
                }
                if (newFactory != null)
                {
                    break;
                }
            }

            return(newFactory);
        }
Esempio n. 15
0
        /// <summary>
        /// The return driver types.
        /// </summary>
        /// <param name="driverTypeId">
        /// The driver type id.
        /// </param>
        /// <returns>
        /// The <see cref="List"/>.
        /// </returns>
        public static List <IDriverType> ReturnDriverTypes(Guid driverTypeId)
        {
            if (DriverTypes == null || !DriverTypes.Any())
            {
                return(null);
            }

            List <IDriverType> result = new List <IDriverType>();

            foreach (Lazy <IDriverType, IDictionary <string, object> > foundDriverType in DriverTypes)
            {
                if (foundDriverType.Value.Id == driverTypeId)
                {
                    if (!result.Any(d => d.Id == foundDriverType.Value.Id))
                    {
                        result.Add(foundDriverType.Value);
                    }
                }
            }

            return(result);
        }
        /// <summary>
        /// Converts a DriverTypes enum to the string equivalent
        /// </summary>
        /// <param name="driverType">The requested type</param>
        /// <returns>The equivalent in string form, often used to search the registry</returns>
        public static string DriverString(DriverTypes driverType)
        {
            switch (driverType)
            {
            case DriverTypes.Camera:
                return("Camera");

            case DriverTypes.CoverCalibrator:
                return("CoverCalibrator");

            case DriverTypes.Dome:
                return("Dome");

            case DriverTypes.FilterWheel:
                return("FilterWheel");

            case DriverTypes.Focuser:
                return("Focuser");

            case DriverTypes.ObservingConditions:
                return("ObservingConditions");

            case DriverTypes.Rotator:
                return("Rotator");

            case DriverTypes.SafetyMonitor:
                return("SafetyMonitor");

            case DriverTypes.Switch:
                return("Switch");

            case DriverTypes.Telescope:
                return("Telescope");

            case DriverTypes.Video:
                return("Video");
            }
            throw new Exception("Unknown device type requested;");
        }
Esempio n. 17
0
        public SegmentFactory GetFactory(DriverTypes driverType)
        {
            SegmentFactory newFactory = null;

            string driverTypeDescription = EnumUtils.stringValueOf(driverType);

            // Using custom attributes on the defined HL7 Segment Factory classes, we
            // can find the proper class to create an instance of. Doing it this
            // way, this factory class does not have to be updated each time a
            // new driver type is added.
            var types = from a in AppDomain.CurrentDomain.GetAssemblies()
                        from t in a.GetTypes()
                        where t.IsDefined(typeof(HL7SegmentFactoryAttribute), true)
                        select t;

            foreach (Type t in types)
            {
                var attributes = t.GetCustomAttributes(typeof(HL7SegmentFactoryAttribute), true);
                foreach (HL7SegmentFactoryAttribute a in attributes)
                {
                    if (a.DriverType == driverTypeDescription)
                    {
                        object[] constructorArgs =
                                        {
                                           _delimiters
                                        };
                        object obj = Activator.CreateInstance(t, constructorArgs);

                        newFactory = (SegmentFactory)obj;
                        break;
                    }
                }
                if (newFactory != null)
                    break;
            }

            return newFactory;
        }
Esempio n. 18
0
        public static void Initialize(DriverTypes driverType)
        {
            switch (driverType)
            {
            case DriverTypes.Chrome:
                Instance = new ChromeDriver();
                break;

            case DriverTypes.FireFox:
                Instance = new FirefoxDriver();
                break;

            case DriverTypes.InternetExplorer:
                Instance = new InternetExplorerDriver();
                break;

            default:
                Instance = new ChromeDriver();
                break;
            }
            //ChromeOptions options = new ChromeOptions();
            //driver = new RemoteWebDriver(new Uri(HUB_URL), options);
        }
Esempio n. 19
0
 public T Init <T>(DriverTypes driverType = DriverTypes.Chrome) where T : Application
 {
     DriverName = UseDriver(driverType);
     return(Init <T>(DriverName));
 }
Esempio n. 20
0
 public static T Init <T>(Type siteType, DriverTypes driverType = DriverTypes.Chrome) where T : Application
 {
     return(Init <T>(siteType, UseDriver(driverType)));
 }
Esempio n. 21
0
 private static RemoteWebDriver DriverFactory(DriverTypes driverType, string driverPath)
 => SeleniumDriverFactory.Factory(
     Type.GetType(driverType.ToString()),
     driverPath);
Esempio n. 22
0
        public void Initialize(DriverTypes driverType, string driverPath)
        {
            _driver = DriverFactory(driverType, driverPath);

            _translator = new SeleniumGoogleTranslator();
        }
Esempio n. 23
0
 public static string UseDriver(DriverTypes driverName)
 {
     return WebDriverFactory.RegisterDriver(driverName);
 }
Esempio n. 24
0
 public static string UseDriver(DriverTypes driverName)
 {
     return(WebDriverFactory.RegisterDriver(driverName));
 }
 /// <summary>
 /// Searches the ASCOM Registry for all drivers of a specified driver type
 /// </summary>
 /// <param name="DeviceType">The driver type to search for as a DriverType.</param>
 /// <returns>Returns a list of found ASCOM Devices, this includes ProgID and the friendly Name</returns>
 public static List <ASCOMRegistration> GetDrivers(DriverTypes DeviceType)
 {
     return(GetDrivers(DriverString(DeviceType)));
 }
Esempio n. 26
0
 public virtual void SetDriverType(DriverTypes driverType)
 {
     _driverType = driverType;
 }
Esempio n. 27
0
 private string RegisterLocalDriver(DriverTypes driverType)
 {
     return(RegisterDriver(GetDriverName(_driverNamesDictionary[driverType]),
                           () => WebDriverSettings(_driversDictionary[driverType](DriverPath))));
 }
Esempio n. 28
0
 public async Task InitializeAsync(DriverTypes driverType, string driverPath)
 => await _service.InitializeAsync(driverType, driverPath);
Esempio n. 29
0
 public IWebDriver GetDriver(DriverTypes driverType)
 {
     return(GetDriver(_driverNamesDictionary[driverType]));
 }
Esempio n. 30
0
 public virtual void SetDriverType(DriverTypes driverType)
 {
     _driverType = driverType;
 }
Esempio n. 31
0
 public static IWebDriver GetDriver(DriverTypes driverName)
 => driverName switch
 {
Esempio n. 32
0
 public ActivityRegistration(Type activityType, Type driverType) : this(activityType)
 {
     DriverTypes.Add(driverType);
 }
        private IWebDriver GetDriver(DriverTypes type)
        {
            IWebDriver driver = null;
            switch (type)
            {
                case DriverTypes.IE:
                    driver = new InternetExplorerDriver(
                        new InternetExplorerOptions
                        {
                            UnexpectedAlertBehavior = InternetExplorerUnexpectedAlertBehavior.Default,
                            EnableNativeEvents = true,
                            //ForceCreateProcessApi = true,
                            //BrowserCommandLineArguments = "-private",
                            EnsureCleanSession = true
                        });
                    driver = new NgWebDriver(driver);
                    break;

                case DriverTypes.Chrome:
                    ChromeOptions options = new ChromeOptions();
                    options.AddArgument("--disable-plugins");
                    driver = new ChromeDriver(options);
                    driver = new NgWebDriver(driver);
                    break;
            }
            ((NgWebDriver)driver).IgnoreSynchronization = true;
            return driver;
        }