UI tests reside in the UITests project. WinAppDriver is used for navigation and Axe.Windows is used for accessibility scanning. UI tests are automatically run as a part of the PR build.
- To run tests locally, WinAppDriver must already be running. Once WinAppDriver is open, simply run the UI tests from Visual Studio the same way unit tests are run.
- UI tests are automatically run as a part of Accessibility Insights for Windows's PR build. Results can be viewed in the Tests tab of a specific build. The following attachments are associated with UI tests:
- Screen capture. You can download a screen capture video of any UI test.
- Events log. In case a crash occurs, we attach the Windows event log events that were captured during a UI test if there were any such events.
- A11y test file. If an accessibility issue is found during a UI test, we attach the corresponding .a11ytest file. You can open this with Accessibility Insights for Windows.
- Test classes inherit from
AIWinSession. - Each test class covers an AI-Win usage scenario. For example, the
LoadTestFiletest covers the scenario of loading a test file and inspecting individual test results. Each test class has at least the following methods:- A
TestMethodnamedNameOfTestClassTeststhat performs the desired validation. - A
TestInitializemethod which callsSetup(). This will launch Accessibility Insights for Windows. - A
TestCleanupmethod which callsTearDown(). This will exit Accessibility Insights for Windows.
- A
- Each test uses appropriate
Assertmethods to validate its conditions. driver.ScanAIWinis called to assess the accessibility of the UI being tested.- Navigation related functionality (such as entering the settings page or returning to live mode) is separated into the appropriate mode-specific classes in the
UILibraryfolder.- If you add functionality related to navigating Accessibility Insights for Windows or that you expect to reuse in other UI tests, consider adding that functionality to the appropriate class in
UILibraryrather than to the specific test.
- If you add functionality related to navigating Accessibility Insights for Windows or that you expect to reuse in other UI tests, consider adding that functionality to the appropriate class in
- UI Automation AutomationIDs should be used when navigating to specific controls in Accessibility Insights for Windows. When you need to navigate to a specific control which does not already have a specific AutomationID set, refer to the following steps:
-
Add a property to
AccessibilityInsights.SharedUx.Properties.AutomationIDswith this format:public static string <NameOfParentControl><NameOfControl><ControlType>){ get; } = nameof (<NameOfParentControl><NameOfControl><ControlType>);
For example, the entry for the Expand All button in
AutomatedChecksControllooks like:public static string AutomatedChecksExpandAllButton { get; } = nameof(AutomatedChecksExpandAllButton);
-
Reference that property when setting the
AutomationIdproperty of your control in xaml:AutomationProperties.AutomationId="{x:Static Properties:AutomationIDs.AutomatedChecksExpandAllButton}"
-
Use that property when navigating Accessibility Insights for Windows in the UI test:
var element = driver.FindElementByAccessibilityId(AutomationIDs.AutomatedChecksExpandAllButton)
-