CodedUI Tests and Windows Hello in UWP

Using Visual Studio CodedUI Automated Tests for logging in via Windows Hello / Micrcosoft Passport!

We're implementing the ability to use Windows Hello, or Microsoft Passport, to log into our app.
The exact mechanism of how we handle credentials isn't important here. As the title suggests, this is about using the CodedUI tests for getting Automated Tests in place.

We had a short struggle around getting the CodedUI / UIMap to recognize the windows. Using the standard Name or AutomationID Search Criteria wasn't working for us to get the automation tool to find wasn't working.

In my mad flailing... because how else do you debug?... After a number of spins and incorrect attempts - I finally got to a working solution.

We set up the Search Criteria to use the ClassName; which for the Windows Hello Security PopUp is "Credential Dialog Xaml Host".

Our code in the UiMap.Designer.cs now looks like

public class UIWindowsSecurityWindow : XamlWindow
{
   public UIWindowsSecurityWindow()
    {
        #region Search Criteria
        this.SearchProperties[XamlControl.PropertyNames.ClassName] = "Credential Dialog Xaml Host";
        this.WindowTitles.Add("Windows Security");
        #endregion

        ...
    }
}

We also had to modify the UiMap.uitest to get it updated for regeneration to produce the Search Criteria we need.
We could do a non-generated file and get it in; but meh - I'd prefer to hold off on introducing that until it's a full requirement.
In UiMap.uitest there should be a section (assuming you've already tried to select the PasswordField_4 control via the CodedUi tool) that starts like

<TopLevelWindow ControlType="Window" Id="UIWindowsSecurityWindow" FriendlyName="Windows Security" SpecialControlType="None">

There should be a section the has the <WindowTitle>Windows Security</WindowTitle> followed by <AndCondition>. It's in this <AndCondition> block we'll add

<PropertyCondition Name="ClassName">Credential Dialog Xaml Host</PropertyCondition>

You can probably remove the <PropertyCondition Name="Name"> element. We did; and it works, so...

We disabled the facial recognition and just use the PIN feature. This has no bearing on the app; it's all system controlled and makes our tests simpler.

I'm tossing this up as a quick post because it's something we encountered that I actually found zero information online for. So here you go!

Show Comments