Example #1
0
 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);
     }
 }
Example #2
0
        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);
                }
        }
Example #3
0
        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"));
                }
            }
        }