Skip to content
Permalink
Browse files

Add page.accessibility.snapshot tests (#1020)

* added roledescription, orientation, autocomplete, multiselectable & keyshortcuts tests

* added missing test
  • Loading branch information...
Meir017 authored and kblok committed Mar 18, 2019
1 parent bdef51c commit 23a64347ff936abd4b2388dfcaf64daac4242ca3
Showing with 50 additions and 0 deletions.
  1. +50 −0 lib/PuppeteerSharp.Tests/AccessibilityTests/AccessibilityTests.cs
@@ -146,6 +146,46 @@ public async Task ShouldReportUninterestingNodes()
})));
}

[Fact]
public async Task RoleDescription()
{
await Page.SetContentAsync("<div tabIndex=-1 aria-roledescription='foo'>Hi</div>");
var snapshot = await Page.Accessibility.SnapshotAsync();
Assert.Equal("foo", snapshot.Children[0].RoleDescription);
}

[Fact]
public async Task Orientation()
{
await Page.SetContentAsync("<a href='' role='slider' aria-orientation='vertical'>11</a>");
var snapshot = await Page.Accessibility.SnapshotAsync();
Assert.Equal("vertical", snapshot.Children[0].Orientation);
}

[Fact]
public async Task AutoComplete()
{
await Page.SetContentAsync("<input type='number' aria-autocomplete='list' />");
var snapshot = await Page.Accessibility.SnapshotAsync();
Assert.Equal("list", snapshot.Children[0].AutoComplete);
}

[Fact]
public async Task MultiSelectable()
{
await Page.SetContentAsync("<div role='grid' tabIndex=-1 aria-multiselectable=true>hey</div>");
var snapshot = await Page.Accessibility.SnapshotAsync();
Assert.True(snapshot.Children[0].Multiselectable);
}

[Fact]
public async Task KeyShortcuts()
{
await Page.SetContentAsync("<div role='grid' tabIndex=-1 aria-keyshortcuts='foo'>hey</div>");
var snapshot = await Page.Accessibility.SnapshotAsync();
Assert.Equal("foo", snapshot.Children[0].KeyShortcuts);
}

[Fact]
public async Task ShouldNotReportTextNodesInsideControls()
{
@@ -265,6 +305,16 @@ public async Task PlainTextFieldWithTabindexAndWithoutRoleShouldNotHaveContent()
(await Page.Accessibility.SnapshotAsync()).Children[0]);
}

[Fact]
public async Task PlainTextFieldWithoutRoleShouldNotHaveContent()
{
await Page.SetContentAsync(
"<div contenteditable='plaintext-only'>Edit this image:<img src='fakeimage.png' alt='my fake image'></div>");
var snapshot = await Page.Accessibility.SnapshotAsync();
Assert.Equal("GenericContainer", snapshot.Children[0].Role);
Assert.Equal(string.Empty, snapshot.Children[0].Name);
}

[Fact]
public async Task NonEditableTextboxWithRoleAndTabIndexAndLabelShouldNotHaveChildren()
{

0 comments on commit 23a6434

Please sign in to comment.
You can’t perform that action at this time.