forked from microsoft/WinUI-Gallery
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Test to Scan All Pages for Axe Issues (microsoft#1361)
<!--- Provide a general summary of your changes in the Title above --> ## Description <!--- Describe your changes in detail --> - Add a test that physically navigates to each page via NavView and check for Axe issues. - Utilizes DynamicData attribute to create grouped tests based on section category (ie. TreeView parent) - This also tests for run-time crashes with each page. - Miscellaneous Axe fixes. ## Types of changes <!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change)
- Loading branch information
Showing
23 changed files
with
192 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Microsoft.VisualStudio.TestPlatform; | ||
using OpenQA.Selenium.Appium.Windows; | ||
using System; | ||
using System.Linq; | ||
using System.Text.Json; | ||
using System.IO; | ||
using System.Collections.ObjectModel; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Xml; | ||
using System.Reflection; | ||
using Newtonsoft.Json; | ||
|
||
namespace UITests.Tests | ||
{ | ||
[TestClass] | ||
public class AxeScanAll : TestBase | ||
{ | ||
public static readonly string jsonUri = "ControlInfoData.json"; | ||
public static new WindowsDriver<WindowsElement> Session => SessionManager.Session; | ||
|
||
public static string[] ExclusionList = | ||
{ | ||
"WebView2", // 46668961: Web contents from WebView2 are throwing null BoundingRectangle errors. | ||
"Icons" // https://github.com/CommunityToolkit/Windows/issues/240 External toolkit SettingsExpander does not pass Axe testing | ||
}; | ||
|
||
public class ControlInfoData | ||
{ | ||
public List<Group> Groups { get; set; } | ||
} | ||
|
||
public class Group | ||
{ | ||
[JsonProperty("UniqueId")] | ||
public string UniqueId { get; set; } | ||
|
||
[JsonProperty("Items")] | ||
public List<Item> Items { get; set; } | ||
} | ||
|
||
public class Item | ||
{ | ||
[JsonProperty("UniqueId")] | ||
public string UniqueId { get; set; } | ||
} | ||
|
||
private static IEnumerable<object[]> TestData() | ||
{ | ||
var testCases = new List<object[]>(); | ||
|
||
string jsonContent = System.IO.File.ReadAllText(jsonUri); | ||
var controlInfoData = JsonConvert.DeserializeObject<ControlInfoData>(jsonContent); | ||
|
||
foreach (var group in controlInfoData.Groups) | ||
{ | ||
var sectionName = group.UniqueId; | ||
|
||
// Select all row names within the current table | ||
var items = group.Items; | ||
|
||
foreach (var item in items) | ||
{ | ||
var pageName = item.UniqueId; | ||
|
||
// Skip pages in the exclusion list. | ||
if (ExclusionList.Contains(pageName)) | ||
{ | ||
continue; | ||
} | ||
testCases.Add(new object[] { sectionName, pageName }); | ||
} | ||
} | ||
|
||
return testCases; | ||
} | ||
|
||
[ClassInitialize] | ||
public static void ClassInitialize(TestContext context) | ||
{ | ||
} | ||
|
||
[TestMethod] | ||
[DynamicData(nameof(TestData), DynamicDataSourceType.Method, DynamicDataDisplayName = nameof(GetCustomDynamicDataDisplayName))] | ||
[TestProperty("Description", "Scan pages in the WinUIGallery for accessibility issues.")] | ||
public void ValidatePageAccessibilityWithAxe(string sectionName, string pageName) | ||
{ | ||
try | ||
{ | ||
// Click into page and check for accessibility issues. | ||
var page = Session.FindElementByAccessibilityId(pageName); | ||
page.Click(); | ||
|
||
AxeHelper.AssertNoAccessibilityErrors(); | ||
} | ||
catch | ||
{ | ||
// If element is not found, expand tree view as it is nested. | ||
var section = Session.FindElementByAccessibilityId(sectionName); | ||
section.Click(); | ||
|
||
// Click into page and check for accessibility issues. | ||
var page = Session.FindElementByAccessibilityId(pageName); | ||
page.Click(); | ||
|
||
AxeHelper.AssertNoAccessibilityErrors(); | ||
} | ||
} | ||
|
||
public static string GetCustomDynamicDataDisplayName(MethodInfo methodInfo, object[] data) | ||
{ | ||
return string.Format("Validate{0}PageAccessibility", data[1]); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.