How to use PageBringToFrontTests method of PuppeteerSharp.Tests.HeadfulTests.PageBringToFrontTests class

Best Puppeteer-sharp code snippet using PuppeteerSharp.Tests.HeadfulTests.PageBringToFrontTests.PageBringToFrontTests

Run Puppeteer-sharp automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.


Source: PageBringToFrontTests.cs Github

1using System;
2using System.Linq;
3using System.Threading.Tasks;
4using PuppeteerSharp.Helpers;
5using PuppeteerSharp.Tests.Attributes;
6using PuppeteerSharp.Xunit;
7using Xunit;
8using Xunit.Abstractions;
10namespace PuppeteerSharp.Tests.HeadfulTests
12    [Collection(TestConstants.TestFixtureCollectionName)]
13    public class PageBringToFrontTests : PuppeteerBaseTest
14    {
15        public PageBringToFrontTests(ITestOutputHelper output) : base(output)
16        {
17        }
19        [PuppeteerTest("headful.spec.ts", "Page.bringToFront", "should work")]
20        [SkipBrowserFact(skipFirefox: true)]
21        public async Task ShouldWork()
22        {
23            await using (var browserWithExtension = await Puppeteer.LaunchAsync(
24                TestConstants.BrowserWithExtensionOptions(),
25                TestConstants.LoggerFactory))
26            await using (var page = await browserWithExtension.NewPageAsync())
27            {
28                await page.GoToAsync(TestConstants.EmptyPage);
29                Assert.Equal("visible", await page.EvaluateExpressionAsync<string>("document.visibilityState"));
31                var newPage = await browserWithExtension.NewPageAsync();
32                await newPage.GoToAsync(TestConstants.EmptyPage);
33                Assert.Equal("hidden", await page.EvaluateExpressionAsync<string>("document.visibilityState"));
34                Assert.Equal("visible", await newPage.EvaluateExpressionAsync<string>("document.visibilityState"));
36                await page.BringToFrontAsync();
37                Assert.Equal("visible", await page.EvaluateExpressionAsync<string>("document.visibilityState"));
38                Assert.Equal("hidden", await newPage.EvaluateExpressionAsync<string>("document.visibilityState"));
40                await newPage.CloseAsync();
41            }
42        }
43    }
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Most used method in PageBringToFrontTests

Trigger PageBringToFrontTests code on LambdaTest Cloud Grid

Execute automation tests with PageBringToFrontTests on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)