public async Task ShouldCloseTheBrowserWhenTheConnectedProcessCloses() { var browserClosedTaskWrapper = new TaskCompletionSource <bool>(); using var browserFetcher = new BrowserFetcher(Product.Chrome); var ChromiumLauncher = new ChromiumLauncher( (await browserFetcher.GetRevisionInfoAsync()).ExecutablePath, new LaunchOptions { Headless = true }); await ChromiumLauncher.StartAsync().ConfigureAwait(false); var browser = await Puppeteer.ConnectAsync(new ConnectOptions { BrowserWSEndpoint = ChromiumLauncher.EndPoint }); browser.Disconnected += (_, _) => { browserClosedTaskWrapper.SetResult(true); }; KillProcess(ChromiumLauncher.Process.Id); await browserClosedTaskWrapper.Task; Assert.True(browser.IsClosed); }
public async Task ShouldDumpBrowserProcessStderr() { var success = false; using var browserFetcher = new BrowserFetcher(Product.Chrome); var process = GetTestAppProcess( "PuppeteerSharp.Tests.DumpIO", $"\"{(await browserFetcher.GetRevisionInfoAsync().ConfigureAwait(false)).ExecutablePath}\""); process.ErrorDataReceived += (_, e) => { success |= e.Data != null && e.Data.Contains("DevTools listening on ws://"); }; process.Start(); process.BeginErrorReadLine(); process.WaitForExit(); Assert.True(success); }