How to use RootOptionTests method of PuppeteerSharp.Tests.AccesibilityTests.RootOptionTests class

Best Puppeteer-sharp code snippet using PuppeteerSharp.Tests.AccesibilityTests.RootOptionTests.RootOptionTests

Run Puppeteer-sharp automation tests on LambdaTest cloud grid

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

RootOptionTests.cs

Source: RootOptionTests.cs Github

copy
1using System.Threading.Tasks;
2using PuppeteerSharp.PageAccessibility;
3using Xunit;
4using Xunit.Abstractions;
5
6namespace PuppeteerSharp.Tests.AccesibilityTests
7{
8    [Collection(TestConstants.TestFixtureCollectionName)]
9    public class RootOptionTests : PuppeteerPageBaseTest
10    {
11        public RootOptionTests(ITestOutputHelper output) : base(output)
12        {
13        }
14
15        [Fact]
16        public async Task ShouldWorkAButton()
17        {
18            await Page.SetContentAsync("<button>My Button</button>");
19
20            var button = await Page.QuerySelectorAsync("button");
21            Assert.Equal(
22                new SerializedAXNode
23                {
24                    Role = "button",
25                    Name = "My Button"
26                },
27                await Page.Accessibility.SnapshotAsync(new AccessibilitySnapshotOptions { Root = button }));
28        }
29
30        [Fact]
31        public async Task ShouldWorkAnInput()
32        {
33            await Page.SetContentAsync("<input title='My Input' value='My Value'>");
34
35            var input = await Page.QuerySelectorAsync("input");
36            Assert.Equal(
37                new SerializedAXNode
38                {
39                    Role = "textbox",
40                    Name = "My Input",
41                    Value = "My Value"
42                },
43                await Page.Accessibility.SnapshotAsync(new AccessibilitySnapshotOptions { Root = input }));
44        }
45
46        [Fact]
47        public async Task ShouldWorkAMenu()
48        {
49            await Page.SetContentAsync(@"
50            <div role=""menu"" title=""My Menu"" >
51              <div role=""menuitem"">First Item</div>
52              <div role=""menuitem"">Second Item</div>
53              <div role=""menuitem"">Third Item</div>
54            </div>
55            ");
56
57            var menu = await Page.QuerySelectorAsync("div[role=\"menu\"]");
58            Assert.Equal(
59                new SerializedAXNode
60                {
61                    Role = "menu",
62                    Name = "My Menu",
63                    Children = new[]
64                    {
65                        new SerializedAXNode
66                        {
67                            Role = "menuitem",
68                            Name = "First Item"
69                        },
70                        new SerializedAXNode
71                        {
72                            Role = "menuitem",
73                            Name = "Second Item"
74                        },
75                        new SerializedAXNode
76                        {
77                            Role = "menuitem",
78                            Name = "Third Item"
79                        }
80                    }
81                },
82                await Page.Accessibility.SnapshotAsync(new AccessibilitySnapshotOptions { Root = menu }));
83        }
84
85        [Fact]
86        public async Task ShouldReturnNullWhenTheElementIsNoLongerInDOM()
87        {
88            await Page.SetContentAsync("<button>My Button</button>");
89            var button = await Page.QuerySelectorAsync("button");
90            await Page.EvaluateFunctionAsync("button => button.remove()", button);
91            Assert.Null(await Page.Accessibility.SnapshotAsync(new AccessibilitySnapshotOptions { Root = button }));
92        }
93
94        [Fact]
95        public async Task ShouldSupportTheInterestingOnlyOption()
96        {
97            await Page.SetContentAsync("<div><button>My Button</button></div>");
98            var div = await Page.QuerySelectorAsync("div");
99            Assert.Null(await Page.Accessibility.SnapshotAsync(new AccessibilitySnapshotOptions
100            {
101                Root = div
102            }));
103            Assert.Equal(
104                new SerializedAXNode
105                {
106                    Role = "GenericContainer",
107                    Name = "",
108                    Children = new[]
109                    {
110                        new SerializedAXNode
111                        {
112                            Role = "button",
113                            Name = "My Button"
114                        }
115                    }
116                },
117                await Page.Accessibility.SnapshotAsync(new AccessibilitySnapshotOptions
118                {
119                    Root = div,
120                    InterestingOnly = false
121                }));
122        }
123    }
124}
125
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 RootOptionTests code on LambdaTest Cloud Grid

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