How to use ShouldWork method of PuppeteerSharp.Tests.CookiesTests.DeleteCookiesTests class

Best Puppeteer-sharp code snippet using PuppeteerSharp.Tests.CookiesTests.DeleteCookiesTests.ShouldWork

Run Puppeteer-sharp automation tests on LambdaTest cloud grid

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

DeleteCookiesTests.cs

Source: DeleteCookiesTests.cs Github

copy
1using System.Threading.Tasks;
2using PuppeteerSharp.Tests.Attributes;
3using PuppeteerSharp.Xunit;
4using Xunit;
5using Xunit.Abstractions;
6
7namespace PuppeteerSharp.Tests.CookiesTests
8{
9    [Collection(TestConstants.TestFixtureCollectionName)]
10    public class DeleteCookiesTests : PuppeteerPageBaseTest
11    {
12        public DeleteCookiesTests(ITestOutputHelper output) : base(output)
13        {
14        }
15
16        [PuppeteerTest("cookies.spec.ts", "Page.deleteCookie", "should work")]
17        [SkipBrowserFact(skipFirefox: true)]
18        public async Task ShouldWork()
19        {
20            await Page.GoToAsync(TestConstants.ServerUrl + "/grid.html");
21            await Page.SetCookieAsync(new CookieParam
22            {
23                Name = "cookie1",
24                Value = "1"
25            }, new CookieParam
26            {
27                Name = "cookie2",
28                Value = "2"
29            }, new CookieParam
30            {
31                Name = "cookie3",
32                Value = "3"
33            });
34            Assert.Equal("cookie1=1; cookie2=2; cookie3=3", await Page.EvaluateExpressionAsync<string>("document.cookie"));
35            await Page.DeleteCookieAsync(new CookieParam { Name = "cookie2" });
36            Assert.Equal("cookie1=1; cookie3=3", await Page.EvaluateExpressionAsync<string>("document.cookie"));
37        }
38    }
39}
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 DeleteCookiesTests

Trigger ShouldWork code on LambdaTest Cloud Grid

Execute automation tests with ShouldWork 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)