public static IWebDriver Create() { if (InstalledBrowsers.Contains("chrome")) { return(new ChromeDriver()); } else if (InstalledBrowsers.Contains("firefox")) { return(new FirefoxDriver()); } else { //return new EdgeDriver(); //return new InternetExplorerDriver(); throw new InvalidOperationException("Install Chrome or Firefox web browser on your computer. Please..."); } }
public static IWebDriver GetFirefoxBrowser() { InstalledBrowsers .Any(d => d.Name.ContainsIgnoreCase("firefox") && d.InstallationPath.HasValue()) .Should() .BeTrue( "Firefox is not installed in your computer. Make sure you installed firefox in your machine and InstalledBrowsers is listing the browser"); FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(DriverFolder); service.FirefoxBinaryPath = InstalledBrowsers .FirstOrDefault(d => d.Name.ContainsIgnoreCase("firefox"))?.InstallationPath; service.HideCommandPromptWindow = true; return(new FirefoxDriver(service, FirefoxOptions)); }