diff --git a/dotnet/src/webdriver/Navigator.cs b/dotnet/src/webdriver/Navigator.cs index 0b513d915fbe9..cfd124900f388 100644 --- a/dotnet/src/webdriver/Navigator.cs +++ b/dotnet/src/webdriver/Navigator.cs @@ -30,6 +30,13 @@ internal class Navigator : INavigation { private WebDriver driver; private string browsingContextId; + private static readonly Dictionary PageLoadStrategyMapper = new() + { + {"normal", ReadinessState.Complete}, + {"eager", ReadinessState.Interactive}, + {"none", ReadinessState.None} + }; + private ReadinessState readinessState; /// /// Initializes a new instance of the class @@ -38,8 +45,9 @@ internal class Navigator : INavigation public Navigator(WebDriver driver) { this.driver = driver; - // TODO: store the value of the current window's context id on the driver object this.browsingContextId = driver.CurrentWindowHandle; + string strategyCap = driver.Capabilities.GetCapability("pageLoadStrategy") as string; + this.readinessState = strategyCap == null ? ReadinessState.Complete : PageLoadStrategyMapper[strategyCap]; } /// @@ -128,7 +136,11 @@ public async Task GoToUrlAsync(string url) if (this.driver.BiDiDriver != null) { - await driver.BiDiDriver.BrowsingContext.NavigateAsync(new NavigateCommandParameters(this.browsingContextId, url)).ConfigureAwait(false); + NavigateCommandParameters navigateCommandParameters = new NavigateCommandParameters(this.browsingContextId, url) + { + Wait = this.readinessState + }; + await driver.BiDiDriver.BrowsingContext.NavigateAsync(navigateCommandParameters).ConfigureAwait(false); } else { @@ -187,7 +199,10 @@ public async Task RefreshAsync() if (this.driver.BiDiDriver != null) { var reloadCommandParameters = - new ReloadCommandParameters(this.browsingContextId); + new ReloadCommandParameters(this.browsingContextId) + { + Wait = this.readinessState + }; await this.driver.BiDiDriver.BrowsingContext.ReloadAsync(reloadCommandParameters).ConfigureAwait(false); } else