我正在尝试学习Appium,并在Windows UWP应用程序测试中使用它。我想自动单击GridView中的项目,但不知道如何将AutomationProperties.AutomationId分配给这些动态生成的UI元素。读this SO post给了我一个线索,但对我没有用。这是我的GridView XAML:
<GridView Name="MoviesListView" ItemsSource="{Binding Films}" Grid.Column="1" IsItemClickEnabled="True" ItemClick="MoviesListView_ItemClick">
<GridView.ItemTemplate>
<DataTemplate x:DataType="mov:Film">
<RelativePanel>
<Image Name="posterImage" MinWidth="100" MaxWidth="150" Margin="0,0,0,10">
<Image.Source>
<BitmapImage UriSource="{Binding FullPosterPath}"/>
</Image.Source>
</Image>
<Border
RelativePanel.AlignLeftWithPanel="True"
RelativePanel.AlignRightWithPanel="True"
RelativePanel.AlignBottomWithPanel="True">
<Border.Background>
<SolidColorBrush
Color="Black"
Opacity="0.5"/>
</Border.Background>
<TextBlock
Name="posterText"
Margin="0,0,0,10"
Width="100"
Text="{x:Bind Title}"
TextWrapping="Wrap"
HorizontalTextAlignment="Center"
Foreground="White"
Opacity="1"/>
</Border>
</RelativePanel>
</DataTemplate>
</GridView.ItemTemplate>
<GridView.ItemContainerStyle>
<Style TargetType="GridViewItem">
<Setter Property="AutomationProperties.AutomationId" Value="{Binding RelativeSource={RelativeSource Self}, Path=Film.Title}"/>
</Style>
</GridView.ItemContainerStyle>
</GridView>
有人可以解释此示例中的绑定路径如何工作吗?如何分配唯一的AutomationId,例如PositionInSet?