Exemple #1
0
 public static void Init(ILogger logger = null, IAssert assert = null,
     TimeoutSettings timeouts = null, IDriver<IWebDriver> driverFactory = null)
 {
     DriverFactory = driverFactory ?? new WebDriverFactory();
     Asserter = assert ?? new WebAssert();
     Timeouts = timeouts ?? new WebTimeoutSettings();
     Logger = logger ?? new LogAgregator(new NUnitLogger(), new Log4Net());
     MapInterfaceToElement.Init(DefaultInterfacesMap);
 }
Exemple #2
0
        public static void InitFromProperties(ILogger logger = null, IAssert assert = null,
            TimeoutSettings timeouts = null, IDriver<IWebDriver> driverFactory = null)
        {
            Init(logger, assert, timeouts, driverFactory);
            JDISettings.InitFromProperties();
            FillFromSettings(p => Domain = p, "Domain");
            FillFromSettings(p => DriverFactory.DriverPath = p, "DriversFolder");

            // FillFromSettings(p => DriverFactory.DriverVersion = p, "DriversVersion");
            // fillAction(p->getDriverFactory().getLatestDriver =
            //        p.toLowerCase().equals("true") || p.toLowerCase().equals("1"), "driver.getLatest");
            // fillAction(p->asserter.doScreenshot(p), "screenshot.strategy");
            FillFromSettings(p =>
            {
                p = p.ToLower();
                if (p.Equals("soft"))
                    p = "any,multiple";
                if (p.Equals("strict"))
                    p = "visible,single";
                if (p.Split(',').Length != 2) return;
                var parameters = p.Split(',').ToList();
                if (parameters.Contains("visible") || parameters.Contains("displayed"))
                    WebDriverFactory.ElementSearchCriteria = el => el.Displayed;
                if (parameters.Contains("any") || parameters.Contains("all"))
                    WebDriverFactory.ElementSearchCriteria = el => el != null;
                if (parameters.Contains("single") || parameters.Contains("displayed"))
                    OnlyOneElementAllowedInSearch = true;
                if (parameters.Contains("multiple") || parameters.Contains("displayed"))
                    OnlyOneElementAllowedInSearch = false;
            }, "SearchElementStrategy");

            FillFromSettings(p =>
            {
                string[] split = null;
                if (p.Split(',').Length == 2)
                    split = p.Split(',');
                if (p.ToLower().Split('x').Length == 2)
                    split = p.ToLower().Split('x');
                if (split != null)
                    BrowserSize = new Size(Parse(split[0]), Parse(split[1]));
            }, "BrowserSize");
        }