/// <inheritdoc /> public async Task WaitForLoadStateAsync(LoadState state, float?timeout) { Task <LoadState> task; Waiter waiter = null; state = state.EnsureDefaultValue(Microsoft.Playwright.LoadState.Load); try { lock (_loadStates) { if (_loadStates.Contains(state)) { return; } waiter = SetupNavigationWaiter(timeout); task = waiter.WaitForEventAsync <LoadState>(this, "LoadState", s => { waiter.Log($" \"{s}\" event fired"); return(s == state); }); } await task.ConfigureAwait(false); } finally { waiter?.Dispose(); } }