@@ -30,6 +30,13 @@ internal class Navigator : INavigation
3030 {
3131 private WebDriver driver ;
3232 private string browsingContextId ;
33+ private static readonly Dictionary < string , ReadinessState > PageLoadStrategyMapper = new ( )
34+ {
35+ { "normal" , ReadinessState . Complete } ,
36+ { "eager" , ReadinessState . Interactive } ,
37+ { "none" , ReadinessState . None }
38+ } ;
39+ private ReadinessState readinessState ;
3340
3441 /// <summary>
3542 /// Initializes a new instance of the <see cref="Navigator"/> class
@@ -38,8 +45,9 @@ internal class Navigator : INavigation
3845 public Navigator ( WebDriver driver )
3946 {
4047 this . driver = driver ;
41- // TODO: store the value of the current window's context id on the driver object
4248 this . browsingContextId = driver . CurrentWindowHandle ;
49+ string strategyCap = driver . Capabilities . GetCapability ( "pageLoadStrategy" ) as string ;
50+ this . readinessState = strategyCap == null ? ReadinessState . Complete : PageLoadStrategyMapper [ strategyCap ] ;
4351 }
4452
4553 /// <summary>
@@ -128,7 +136,11 @@ public async Task GoToUrlAsync(string url)
128136
129137 if ( this . driver . BiDiDriver != null )
130138 {
131- await driver . BiDiDriver . BrowsingContext . NavigateAsync ( new NavigateCommandParameters ( this . browsingContextId , url ) ) . ConfigureAwait ( false ) ;
139+ NavigateCommandParameters navigateCommandParameters = new NavigateCommandParameters ( this . browsingContextId , url )
140+ {
141+ Wait = this . readinessState
142+ } ;
143+ await driver . BiDiDriver . BrowsingContext . NavigateAsync ( navigateCommandParameters ) . ConfigureAwait ( false ) ;
132144 }
133145 else
134146 {
@@ -187,7 +199,10 @@ public async Task RefreshAsync()
187199 if ( this . driver . BiDiDriver != null )
188200 {
189201 var reloadCommandParameters =
190- new ReloadCommandParameters ( this . browsingContextId ) ;
202+ new ReloadCommandParameters ( this . browsingContextId )
203+ {
204+ Wait = this . readinessState
205+ } ;
191206 await this . driver . BiDiDriver . BrowsingContext . ReloadAsync ( reloadCommandParameters ) . ConfigureAwait ( false ) ;
192207 }
193208 else
0 commit comments