@@ -30,6 +30,13 @@ internal class Navigator : INavigation
30
30
{
31
31
private WebDriver driver ;
32
32
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 ;
33
40
34
41
/// <summary>
35
42
/// Initializes a new instance of the <see cref="Navigator"/> class
@@ -38,8 +45,9 @@ internal class Navigator : INavigation
38
45
public Navigator ( WebDriver driver )
39
46
{
40
47
this . driver = driver ;
41
- // TODO: store the value of the current window's context id on the driver object
42
48
this . browsingContextId = driver . CurrentWindowHandle ;
49
+ string strategyCap = driver . Capabilities . GetCapability ( "pageLoadStrategy" ) as string ;
50
+ this . readinessState = strategyCap == null ? ReadinessState . Complete : PageLoadStrategyMapper [ strategyCap ] ;
43
51
}
44
52
45
53
/// <summary>
@@ -128,7 +136,11 @@ public async Task GoToUrlAsync(string url)
128
136
129
137
if ( this . driver . BiDiDriver != null )
130
138
{
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 ) ;
132
144
}
133
145
else
134
146
{
@@ -187,7 +199,10 @@ public async Task RefreshAsync()
187
199
if ( this . driver . BiDiDriver != null )
188
200
{
189
201
var reloadCommandParameters =
190
- new ReloadCommandParameters ( this . browsingContextId ) ;
202
+ new ReloadCommandParameters ( this . browsingContextId )
203
+ {
204
+ Wait = this . readinessState
205
+ } ;
191
206
await this . driver . BiDiDriver . BrowsingContext . ReloadAsync ( reloadCommandParameters ) . ConfigureAwait ( false ) ;
192
207
}
193
208
else
0 commit comments