2

I am trying to automate UI testing through WinAppDriver of a UWP app. The doc says that anything that is visible through the inspect.exe (i.e UIAutomation) could be controlled through WinAppDriver. This means the basic controls can be accessed through UIAutomation. And sometimes even content within these controls is accessible through UI Automation. Like the header for a TextBlock or ToggleSwitch, or the popup of a ComboBox.

Encouraged with this, I am modified the ControlTemplate of the common controls to make certain elements of the control visible through UIAutomation. See the example of ToggleSwitch (The default ControlTemplate does not expose the OnContent and OffContent properties of the ToggleSwitch as it is marked with AutomationProperties.AutomationView = "Raw")

However, when I attempted to get the header of the ComboBox, I could not access it through UIAutomation.

<ComboBox x:Name="Box">
    <ComboBox.Header>
        <StackPanel Orientation="Horizontal">
            <TextBlock Text="This is a combobox" x:Name="Block" AutomationProperties.Name="TextBlock1" />
            <FontIcon VerticalAlignment="Top"
                      AutomationProperties.AutomationId="Error"
                      FontFamily="Segoe MDL2 Assets"
                      Margin="2 0"
                      Glyph="&#xEB90;"
                      x:Name="FontIcon"
                      Foreground="DarkRed"/>
        </StackPanel>
    </ComboBox.Header>
    <ComboBoxItem>Green</ComboBoxItem>
    <ComboBoxItem>Red</ComboBoxItem>
</ComboBox>

The ControlTemplate looks similar to other controls like ToggleSwitch and TextBox, but for whatever reason nothing defined in the ControlTemplate is made accessible to UIAutomation, except for the id and the popup list for ComboBox. So my question is what makes certain UI control expose their content (say Header) and some other not?

resp78
  • 1,414
  • 16
  • 37

0 Answers0