So I'm using WinAppDriver to automate the testing of a UWP application written with Xamarin Forms and I am using to inspect.exe to make sure that the AutomationID property is being set properly on all the elements I am accessing, however, there is one particular button element that is being very peculiar. This button does not show up in the UI Automation tree in inspect.exe yet whenever I hover with inspect it can show all of its properties as exepcted.
Here's some details about the buttons weird behavior: The button always exists in the ui of the app The button in question in the ui
The button is able to be inspected by hover with inspect.exe and in the inspect details it shows that it is a child of the expected parent but it does not always show up in the tree meaning I can't always access it with WinAppDriver inspect.exe hover details showing it is getting the correct element and has the automationID I gave it
AddNew button's ancestors. It is an ancestor of the correct parent element
XAML Code for the button:
<Button
Text="{Binding [EntityChoiceViewBackAddNew], Source={x:Static i18n:Translator.Instance}}"
x:Name="AddNew"
AutomationId="AddNew"
AutomationProperties.IsInAccessibleTree="True"
AutomationProperties.Name="AddNew"
Margin="0,0,8,0" VerticalOptions="Center"
Padding="6,0,6,0"
Grid.Row="0" Grid.Column="1"
FontSize="14"
FontAttributes="Bold"
Command="{Binding Path=AddCommand}"
IsVisible="{Binding Path=CanAdd}"
HeightRequest="{OnPlatform iOS=42, Default=36}"
PropertyChanged="AddNewButton_PropertyChanged">
Things I've tried that didn't work:
- Starting a desktop session in winappdriver
- try to find it by it's full xpath, its name
- getting the child elements of it's parent and trying to find it from there
- Adding AutomationProperties.IsInAccessibleTree property
- Setting IsVisible to always true
Anyone have any insight in to how to get this element to display in the tree or a workaround in winappdriver?