public async Task ShouldHaveDefaultUrlWhenLaunchingBrowser() { await using (var browser = await Puppeteer.LaunchAsync( TestConstants.BrowserWithExtensionOptions(), TestConstants.LoggerFactory)) { var pages = (await browser.PagesAsync()).Select(page => page.Url).ToArray(); Assert.Equal(new[] { "about:blank" }, pages); } }
public async Task BackgroundPageTargetTypeShouldBeAvailable() { using (var browserWithExtension = await Puppeteer.LaunchAsync( TestConstants.BrowserWithExtensionOptions(), TestConstants.LoggerFactory)) using (var page = await browserWithExtension.NewPageAsync()) { var backgroundPageTarget = await WaitForBackgroundPageTargetAsync(browserWithExtension); Assert.NotNull(backgroundPageTarget); } }
public async Task TargetPageShouldReturnABackgroundPage() { using (var browserWithExtension = await Puppeteer.LaunchAsync( TestConstants.BrowserWithExtensionOptions(), TestConstants.LoggerFactory)) { var backgroundPageTarget = await WaitForBackgroundPageTargetAsync(browserWithExtension); var page = await backgroundPageTarget.PageAsync(); Assert.Equal(6, await page.EvaluateFunctionAsync <int>("() => 2 * 3")); } }
public async Task TargetPageShouldReturnABackgroundPage() { await using (var browserWithExtension = await Puppeteer.LaunchAsync( TestConstants.BrowserWithExtensionOptions(), TestConstants.LoggerFactory)) { var backgroundPageTarget = await browserWithExtension.WaitForTargetAsync(t => t.Type == TargetType.BackgroundPage); await using (var page = await backgroundPageTarget.PageAsync()) { Assert.Equal(6, await page.EvaluateFunctionAsync <int>("() => 2 * 3")); Assert.Equal(42, await page.EvaluateFunctionAsync <int>("() => window.MAGIC")); } } }