public async Task ShouldNotDeleteDownloadsWhenTheContextCloses()
        {
            var downloadTask = _page.WaitForEvent(PageEvent.Download);

            await TaskUtils.WhenAll(
                downloadTask,
                _page.ClickAsync("a"));

            var    download = downloadTask.Result.Download;
            string path     = await download.GetPathAsync();

            await _context.CloseAsync();

            Assert.True(new FileInfo(path).Exists);
        }
示例#2
0
        private async Task <(IPage, IBrowserContext, System.Func <Task <dynamic> >)> PageWithHAR()
        {
            var             tmp     = new TempDirectory();
            var             harPath = Path.Combine(tmp.Path, "har.json");
            IBrowserContext context = await Browser.NewContextAsync(new() { RecordHarPath = harPath, IgnoreHTTPSErrors = true });

            IPage page = await context.NewPageAsync();

            async Task <dynamic> getContent()
            {
                await context.CloseAsync();

                var content = await File.ReadAllTextAsync(harPath);

                tmp.Dispose();
                return(JsonSerializer.Deserialize <dynamic>(content));
            };

            return(page, context, getContent);
        }
示例#3
0
 /// <inheritdoc cref="IAsyncLifetime.DisposeAsync"/>
 public override Task DisposeAsync()
 => Task.WhenAll(_context.CloseAsync(), base.DisposeAsync());