private static IEnumerable <Process> AllBrowserHandles(SeleniumAdapterBrowserType browserType) { var expectedTitle = SeleniumAdapterBrowserTypeMapper.MainWindowTitleFor[browserType].ToLower(); var allRunningProcesses = Process.GetProcesses(); return(allRunningProcesses.Where(x => x.MainWindowTitle.ToLower().Contains(expectedTitle)).ToList()); }
public void SetBrowserType(SeleniumAdapterBrowserType type) { _browserType = type; if (_webDriver != null) { _webDriver.Dispose(); _webDriver = null; LazyInitialize(); } }
private static IWebDriver ConstructWebDriver(SeleniumAdapterBrowserType browserType) { IWebDriver webDriver = null; switch (browserType) { case SeleniumAdapterBrowserType.InternetExplorer: webDriver = new InternetExplorerDriver(InternetExplorerDriverService.CreateDefaultService()); break; case SeleniumAdapterBrowserType.Firefox: webDriver = new FirefoxDriver(FirefoxDriverService.CreateDefaultService()); break; case SeleniumAdapterBrowserType.Chrome: var path = FileFinder.Find("chromedriver.exe"); var options = new ChromeOptions(); options.AddArguments("disable-extensions"); options.AddArguments("enable-automation"); options.AddArguments("--disable-infobars"); options.AddArguments("--log-level=3"); //options.AddArguments("--start-maximized"); webDriver = new ChromeDriver(Path.GetDirectoryName(path), options); break; default: break; } return(webDriver); }
private static IntPtr FindNewBrowserHandle(IEnumerable <Process> previousBrowsers, SeleniumAdapterBrowserType browserType) { var currentBrowsers = AllBrowserHandles(browserType); var newBrowsers = currentBrowsers.Where(each => !previousBrowsers.Select(x => x.Id).Contains(each.Id)); var theCreatedFirefox = newBrowsers.Single(); if (theCreatedFirefox == null) { throw new ApplicationException("Firefox window was not found"); } return(theCreatedFirefox.MainWindowHandle); }