Skip to content

Commit

Permalink
Added DefaultCommandTimeout = 300 for Chrome and Edge Driver
Browse files Browse the repository at this point in the history
  • Loading branch information
raczeja committed Feb 9, 2023
1 parent 013c6fc commit 4dbdc21
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions Ocaramba.Tests.NUnit/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"FirefoxUseLegacyImplementation": "false",
"PathToFirefoxProfile": "",
"RemoteWebDriverHub": "http://localhost:4444/wd/hub",
"remoteTimeout": "300",
"DriverCapabilities": "Chrome",
"longTimeout": "30",
"mediumTimeout": "10",
Expand Down
17 changes: 12 additions & 5 deletions OcarambaLite/BaseConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,15 +302,22 @@ public static TimeSpan RemoteWebDriverTimeout
{
get
{
int setting = 0;
string setting = null;
#if net47
setting = int.Parse(ConfigurationManager.AppSettings["remoteTimeout"], CultureInfo.InvariantCulture);
setting = ConfigurationManager.AppSettings["remoteTimeout"];
#endif
#if net6_0
setting = int.Parse(Builder["appSettings:remoteTimeout"], CultureInfo.InvariantCulture);
setting = Builder["appSettings:remoteTimeout"];
#endif
Logger.Trace(CultureInfo.CurrentCulture, "Gets the remote timeout from settings file '{0}'", setting);
return new TimeSpan(0, 0, setting);
if (string.IsNullOrEmpty(setting))
{
setting = "300";
}

var timeout = int.Parse(setting, CultureInfo.InvariantCulture);

Logger.Trace(CultureInfo.CurrentCulture, "Gets the remote timeout from settings file '{0}'", timeout);
return new TimeSpan(0, 0, timeout);
}
}

Expand Down
4 changes: 2 additions & 2 deletions OcarambaLite/DriverContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ public void Start()
this.serviceChrome = ChromeDriverService.CreateDefaultService();
this.serviceChrome.LogPath = BaseConfiguration.PathToChromeDriverLog;
this.serviceChrome.EnableVerboseLogging = BaseConfiguration.EnableVerboseLoggingChrome;
this.driver = string.IsNullOrEmpty(BaseConfiguration.PathToChromeDriverDirectory) ? new ChromeDriver(this.serviceChrome, this.SetDriverOptions(this.ChromeOptions)) : new ChromeDriver(BaseConfiguration.PathToChromeDriverDirectory, this.SetDriverOptions(this.ChromeOptions));
this.driver = string.IsNullOrEmpty(BaseConfiguration.PathToChromeDriverDirectory) ? new ChromeDriver(this.serviceChrome, this.SetDriverOptions(this.ChromeOptions), BaseConfiguration.RemoteWebDriverTimeout) : new ChromeDriver(BaseConfiguration.PathToChromeDriverDirectory, this.SetDriverOptions(this.ChromeOptions), BaseConfiguration.RemoteWebDriverTimeout);
break;
case BrowserType.Safari:
this.driver = new SafariDriver(this.SetDriverOptions(this.SafariOptions));
Expand All @@ -641,7 +641,7 @@ public void Start()
}

this.serviceEdge = EdgeDriverService.CreateDefaultService();
this.driver = string.IsNullOrEmpty(BaseConfiguration.PathToEdgeChromiumDriverDirectory) ? new EdgeDriver(this.serviceEdge, this.SetDriverOptions(this.EdgeOptions)) : new EdgeDriver(EdgeDriverService.CreateDefaultService(BaseConfiguration.PathToEdgeChromiumDriverDirectory, @"msedgedriver.exe"), this.SetDriverOptions(this.EdgeOptions));
this.driver = string.IsNullOrEmpty(BaseConfiguration.PathToEdgeChromiumDriverDirectory) ? new EdgeDriver(this.serviceEdge, this.SetDriverOptions(this.EdgeOptions), BaseConfiguration.RemoteWebDriverTimeout) : new EdgeDriver(EdgeDriverService.CreateDefaultService(BaseConfiguration.PathToEdgeChromiumDriverDirectory, @"msedgedriver.exe"), this.SetDriverOptions(this.EdgeOptions), BaseConfiguration.RemoteWebDriverTimeout);
break;
default:
throw new NotSupportedException(
Expand Down

0 comments on commit 4dbdc21

Please sign in to comment.