public static SeleniumWrapper CreateWrapper(string webBrowserName, string url, TimeSpan timeout, bool noWait, AbstractLogger scr, string driversDirectory)
        {
            IntPtr      mainWindowHandle = IntPtr.Zero;
            BrowserType type             = GetBrowserType(webBrowserName);

            if (type == BrowserType.Edge && wrappers.Where(x => x.BrowserType == BrowserType.Edge).Any())
            {
                throw new ApplicationException("Using multiple Edge instances at once is not supported.");
            }
            var driver  = CreateNewWebDriver(webBrowserName, type, out mainWindowHandle, driversDirectory);
            var wrapper = new SeleniumWrapper(driver, mainWindowHandle, type, scr)
            {
                Id = wrappers.Count > 0 ? wrappers.Max(x => x.Id) + 1 : 0
            };

            wrappers.Add(wrapper);
            CurrentWrapper = wrapper;
            if (!string.IsNullOrEmpty(url))
            {
                CurrentWrapper.Navigate(url, timeout, noWait);
            }
            return(CurrentWrapper);
        }
Example #2
0
        public static SeleniumWrapper CreateWrapper(string webBrowserName, string url, TimeSpan timeout, bool noWait, AbstractLogger scr, string driversDirectory, bool silentMode,
                                                    List <object> chromeSwitches = null, Dictionary <string, bool> chromeProfiles = null, int chromePort = 0, bool chromeAttach = false)
        {
            IntPtr      mainWindowHandle = IntPtr.Zero;
            BrowserType type             = GetBrowserType(webBrowserName);

            if (type == BrowserType.Edge && wrappers.Where(x => x.BrowserType == BrowserType.Edge).Any())
            {
                throw new ApplicationException("Using multiple Edge instances at once is not supported.");
            }
            IWebDriver      driver  = CreateNewWebDriver(webBrowserName, type, out mainWindowHandle, driversDirectory, silentMode, chromeSwitches, chromeProfiles, chromePort, chromeAttach);
            SeleniumWrapper wrapper = new SeleniumWrapper(driver, mainWindowHandle, type, scr)
            {
                Id = wrappers.Count > 0 ? wrappers.Max(x => x.Id) + 1 : 0
            };

            wrappers.Add(wrapper);
            CurrentWrapper = wrapper;
            if (!string.IsNullOrEmpty(url))
            {
                CurrentWrapper.Navigate(url, timeout, noWait);
            }
            return(CurrentWrapper);
        }