Skip to content

Commit

Permalink
[dotnet] implement appropriate waiting for bidi navigation based on p…
Browse files Browse the repository at this point in the history
…age load strategy
  • Loading branch information
titusfortner committed May 29, 2024
1 parent 38a94b6 commit 903bc2b
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions dotnet/src/webdriver/Navigator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ internal class Navigator : INavigation
{
private WebDriver driver;
private string browsingContextId;
private static readonly Dictionary<string, ReadinessState> PageLoadStrategyMapper = new()
{
{"normal", ReadinessState.Complete},
{"default", ReadinessState.Complete},
{"eager", ReadinessState.Interactive},
{"none", ReadinessState.None}
};
private ReadinessState readinessState;

/// <summary>
/// Initializes a new instance of the <see cref="Navigator"/> class
Expand Down Expand Up @@ -119,7 +127,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
{
Expand Down Expand Up @@ -172,7 +184,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
Expand Down

0 comments on commit 903bc2b

Please sign in to comment.