Skip to content

Commit

Permalink
#166 added commandTimeout in LocalBrowserFactory (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
knysh authored Mar 4, 2020
1 parent 9d93bf9 commit efa99da
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,39 @@ public LocalBrowserFactory() : base()
private Browser CreateBrowser()
{
var browserProfile = AqualityServices.Get<IBrowserProfile>();
var commandTimeout = AqualityServices.Get<ITimeoutConfiguration>().Command;
var browserName = browserProfile.BrowserName;
var driverSettings = browserProfile.DriverSettings;
RemoteWebDriver driver;
switch (browserName)
{
case BrowserName.Chrome:
SetUpDriver(new ChromeConfig(), driverSettings);
driver = new ChromeDriver((ChromeOptions)driverSettings.DriverOptions);
SetUpDriver(new ChromeConfig(), driverSettings);
driver = new ChromeDriver(ChromeDriverService.CreateDefaultService(),
(ChromeOptions) driverSettings.DriverOptions, commandTimeout);
break;
case BrowserName.Firefox:
SetUpDriver(new FirefoxConfig(), driverSettings);
driver = new FirefoxDriver((FirefoxOptions)driverSettings.DriverOptions);
driver = new FirefoxDriver(FirefoxDriverService.CreateDefaultService(),
(FirefoxOptions) driverSettings.DriverOptions, commandTimeout);
break;
case BrowserName.IExplorer:
SetUpDriver(new InternetExplorerConfig(), driverSettings);
driver = new InternetExplorerDriver((InternetExplorerOptions)driverSettings.DriverOptions);
driver = new InternetExplorerDriver(InternetExplorerDriverService.CreateDefaultService(),
(InternetExplorerOptions) driverSettings.DriverOptions, commandTimeout);
break;
case BrowserName.Edge:
driver = new EdgeDriver((EdgeOptions)driverSettings.DriverOptions);
driver = new EdgeDriver(EdgeDriverService.CreateDefaultService(),
(EdgeOptions) driverSettings.DriverOptions, commandTimeout);
break;
case BrowserName.Safari:
driver = new SafariDriver((SafariOptions)driverSettings.DriverOptions);
driver = new SafariDriver(SafariDriverService.CreateDefaultService(),
(SafariOptions) driverSettings.DriverOptions, commandTimeout);
break;
default:
throw new ArgumentOutOfRangeException($"Browser {browserName} is not supported.");
}

return new Browser(driver);
}

Expand Down

0 comments on commit efa99da

Please sign in to comment.