diff --git a/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/ChromeSettings.cs b/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/ChromeSettings.cs index eb4b5853..d3df132e 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/ChromeSettings.cs +++ b/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/ChromeSettings.cs @@ -30,6 +30,7 @@ public override DriverOptions DriverOptions SetChromePrefs(options); SetCapabilities(options, (name, value) => options.AddAdditionalCapability(name, value, isGlobalCapability: true)); SetChromeArguments(options); + SetPageLoadStratergy(options); return options; } } diff --git a/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/DriverSettings.cs b/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/DriverSettings.cs index 9b9f5a3c..d979dc6b 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/DriverSettings.cs +++ b/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/DriverSettings.cs @@ -24,27 +24,15 @@ protected DriverSettings(ISettingsFile settingsFile) SettingsFile = settingsFile; } - private string DriverSettingsPath => $".driverSettings.{BrowserName.ToString().ToLowerInvariant()}"; - - protected IDictionary BrowserCapabilities => SettingsFile.GetValueOrNew>($"{DriverSettingsPath}.capabilities"); - - protected IDictionary BrowserOptions => SettingsFile.GetValueOrNew>($"{DriverSettingsPath}.options"); - - protected IReadOnlyList BrowserStartArguments => SettingsFile.GetValueListOrEmpty($"{DriverSettingsPath}.startArguments"); - protected ISettingsFile SettingsFile { get; } - protected abstract BrowserName BrowserName { get; } - - protected virtual IDictionary> KnownCapabilitySetters => new Dictionary>(); + public string WebDriverVersion => SettingsFile.GetValueOrDefault($"{DriverSettingsPath}.webDriverVersion", "Latest"); - public abstract string DownloadDirCapabilityKey { get; } + public Architecture SystemArchitecture => SettingsFile.GetValueOrDefault($"{DriverSettingsPath}.systemArchitecture", Architecture.Auto).ToEnum(); public abstract DriverOptions DriverOptions { get; } - public string WebDriverVersion => SettingsFile.GetValueOrDefault($"{DriverSettingsPath}.webDriverVersion", defaultValue: "Latest"); - - public Architecture SystemArchitecture => SettingsFile.GetValueOrDefault($"{DriverSettingsPath}.systemArchitecture", "Auto").ToEnum(); + public PageLoadStrategy PageLoadStrategy => SettingsFile.GetValueOrDefault($"{DriverSettingsPath}.pageLoadStrategy", PageLoadStrategy.Normal).ToEnum(); public virtual string DownloadDir { @@ -60,6 +48,25 @@ public virtual string DownloadDir } } + public abstract string DownloadDirCapabilityKey { get; } + + protected IDictionary BrowserCapabilities => SettingsFile.GetValueOrNew>($"{DriverSettingsPath}.capabilities"); + + protected IDictionary BrowserOptions => SettingsFile.GetValueOrNew>($"{DriverSettingsPath}.options"); + + protected IReadOnlyList BrowserStartArguments => SettingsFile.GetValueListOrEmpty($"{DriverSettingsPath}.startArguments"); + + private string DriverSettingsPath => $".driverSettings.{BrowserName.ToString().ToLowerInvariant()}"; + + protected abstract BrowserName BrowserName { get; } + + protected virtual IDictionary> KnownCapabilitySetters => new Dictionary>(); + + protected void SetPageLoadStratergy(DriverOptions options) + { + options.PageLoadStrategy = PageLoadStrategy; + } + protected void SetCapabilities(DriverOptions options, Action addCapabilityMethod = null) { foreach (var capability in BrowserCapabilities) diff --git a/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/EdgeSettings.cs b/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/EdgeSettings.cs index b21c8a28..dd364166 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/EdgeSettings.cs +++ b/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/EdgeSettings.cs @@ -28,6 +28,7 @@ public override DriverOptions DriverOptions var options = new EdgeOptions(); SetCapabilities(options); SetOptionsByPropertyNames(options); + SetPageLoadStratergy(options); return options; } } diff --git a/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/FirefoxSettings.cs b/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/FirefoxSettings.cs index 65b1ad95..1568a377 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/FirefoxSettings.cs +++ b/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/FirefoxSettings.cs @@ -40,6 +40,7 @@ public override DriverOptions DriverOptions SetCapabilities(options, (name, value) => options.AddAdditionalCapability(name, value, isGlobalCapability: true)); SetFirefoxPrefs(options); SetFirefoxArguments(options); + SetPageLoadStratergy(options); return options; } } diff --git a/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/IDriverSettings.cs b/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/IDriverSettings.cs index a268a1b1..c2f753fe 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/IDriverSettings.cs +++ b/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/IDriverSettings.cs @@ -23,6 +23,11 @@ public interface IDriverSettings /// DriverOptions DriverOptions { get; } + /// + /// WebDriver page load strategy. + /// + PageLoadStrategy PageLoadStrategy { get; } + /// /// Gets download directory for web driver. /// diff --git a/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/InternetExplorerSettings.cs b/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/InternetExplorerSettings.cs index 88a3c073..9a873ef2 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/InternetExplorerSettings.cs +++ b/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/InternetExplorerSettings.cs @@ -41,6 +41,7 @@ public override DriverOptions DriverOptions var options = new InternetExplorerOptions(); SetCapabilities(options); SetOptionsByPropertyNames(options); + SetPageLoadStratergy(options); options.BrowserCommandLineArguments = string.Join(" ", BrowserStartArguments); return options; } diff --git a/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/SafariSettings.cs b/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/SafariSettings.cs index 1a223c9f..469f2622 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/SafariSettings.cs +++ b/Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/SafariSettings.cs @@ -27,6 +27,7 @@ public override DriverOptions DriverOptions var options = new SafariOptions(); SetCapabilities(options); SetOptionsByPropertyNames(options); + SetPageLoadStratergy(options); return options; } } diff --git a/Aquality.Selenium/src/Aquality.Selenium/Resources/settings.json b/Aquality.Selenium/src/Aquality.Selenium/Resources/settings.json index a1379db0..74733687 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Resources/settings.json +++ b/Aquality.Selenium/src/Aquality.Selenium/Resources/settings.json @@ -18,7 +18,8 @@ "download.prompt_for_download": "false", "download.default_directory": "//home//selenium//downloads" }, - "startArguments": [] + "startArguments": [], + "pageLoadStrategy": "Normal" }, "firefox": { "webDriverVersion": "Latest",