public void Dispose() { TimeSpan previousTimeout; lock (timeoutHistory) { previousTimeout = timeoutHistory.Pop(); browser.ChangeBrowserDriverTimeout(previousTimeout); } Log.Info(string.Format("ImplicitWaitScope: Restored Timeout to {0}. {1}", previousTimeout, message ?? string.Empty)); }
public ImplicitWaitScope(IBrowserDriver browser, Stack <TimeSpan> timeoutHistory, TimeSpan timeout, string message = null) { this.message = message; this.browser = browser; this.timeoutHistory = timeoutHistory; lock (timeoutHistory) { timeoutHistory.Push(timeout); browser.ChangeBrowserDriverTimeout(timeout); Log.Info(string.Format("ImplicitWaitScope: Set Timeout to {0}. {1}", timeout, message ?? string.Empty)); } }
public Browser(IRuntimeServices runtimeServices, Settings configuration) { Trace.Write($"Configuration = {(configuration?.ToString() ?? "(null)")}"); this.configuration = configuration ?? throw new MissingConfigurationException("Configuration is missing!"); Log.Info("Initializing Driver..."); var driverFactory = runtimeServices.GetBrowserFactoryBuilder(configuration); var browserName = this.configuration?.WebDriver?.Browser?.BrowserName.ToEnum <BrowserNames>(); Log.Info($"WebDriver.BrowserDriver = {(browserName)}"); browserDriver = driverFactory.Create(browserName ?? BrowserNames.chrome); if (configuration?.WebDriver?.Mode.ToEnum <Modes>() == Modes.browser) { var isMaximized = configuration?.WebDriver?.Browser?.Window?.IsMaximized ?? false; // configuring browser window Log.Info($"BrowserWindow.IsMaximized = {isMaximized}"); if (isMaximized) { MaximizePage(); } else { SetWindowSize(configuration?.WebDriver?.Browser?.Window?.InitialWidth ?? 800, configuration?.WebDriver?.Browser?.Window?.InitialHeight ?? 600); } } var maxWait = configuration?.WebDriver?.MaxWait; long waitMilliseconds = Math.Max(maxWait ?? 0, 60000L); Log.Info($"MaxWait = {waitMilliseconds}ms"); var cfgMaxWait = TimeSpan.FromMilliseconds(waitMilliseconds); // set initial browser driver timeout to configuration or 1 minute if not defined lock (timeoutHistory) { timeoutHistory.Push(cfgMaxWait); browserDriver.ChangeBrowserDriverTimeout(cfgMaxWait); } FrameworkInit(runtimeServices); }
public Browser(Settings configuration) { this.configuration = configuration; var driverFactory = new SeleniumBrowserFactory(configuration); var browserName = configuration.WebDriver.BrowserDriver.ToEnum <BrowserNames>(); browserDriver = driverFactory.Create(browserName); var cfgMaxWait = TimeSpan.FromMilliseconds(configuration.MaxWait == 0 ? 60000 : configuration.MaxWait); // set initial browser driver timeout to configuration or 1 minute if not defined lock (timeoutHistory) { timeoutHistory.Push(cfgMaxWait); browserDriver.ChangeBrowserDriverTimeout(cfgMaxWait); } }