How to use StopAsync method of PuppeteerSharp.TestServer.SimpleServer class

Best Puppeteer-sharp code snippet using PuppeteerSharp.TestServer.SimpleServer.StopAsync

Run Puppeteer-sharp automation tests on LambdaTest cloud grid

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

PuppeteerLoaderFixture.cs

Source: PuppeteerLoaderFixture.cs Github

copy
1using PuppeteerSharp.TestServer;
2using System;
3using System.Threading.Tasks;
4
5namespace PuppeteerSharp.Tests
6{
7    public class PuppeteerLoaderFixture : IDisposable
8    {
9        public static SimpleServer Server { get; private set; }
10        public static SimpleServer HttpsServer { get; private set; }
11
12        public PuppeteerLoaderFixture()
13        {
14            SetupAsync().GetAwaiter().GetResult();
15        }
16
17        public void Dispose()
18        {
19            Task.WaitAll(Server.StopAsync(), HttpsServer.StopAsync());
20        }
21
22        private async Task SetupAsync()
23        {
24            var downloaderTask = Downloader.CreateDefault().DownloadRevisionAsync(TestConstants.ChromiumRevision);
25
26            Server = SimpleServer.Create(TestConstants.Port, TestUtils.FindParentDirectory("PuppeteerSharp.TestServer"));
27            HttpsServer = SimpleServer.CreateHttps(TestConstants.HttpsPort, TestUtils.FindParentDirectory("PuppeteerSharp.TestServer"));
28
29            var serverStart = Server.StartAsync();
30            var httpsServerStart = HttpsServer.StartAsync();
31
32            await Task.WhenAll(downloaderTask, serverStart, httpsServerStart);
33        }
34    }
35}
36
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

Trigger StopAsync code on LambdaTest Cloud Grid

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

Test now for Free
LambdaTestX

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
Sarah

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)