我試圖建立一個UI測試在Xamarin窗體項目UITest上Xamarin寫作形式StyleId的標籤,而不是ID
我跟着引導here並添加StyleId到我的用戶名控制
<Entry x:Name="username_name"
StyleId="username_styleid"
Text="{Binding Username, Mode=TwoWay}"
IsEnabled="{Binding IsBusy, Converter={StaticResource ReverseBoolConverter}}"
Style="{StaticResource TextboxLight}"
Placeholder="{Binding UsernameLabel}" />
我添加代碼裝入Android MainActivity
Forms.ViewInitialized += (sender, e) => {
if (!string.IsNullOrWhiteSpace(e.View.StyleId))
{
e.NativeView.ContentDescription = e.View.StyleId;
}
};
當運行測試和使用REPL,我可以看到StyleId已經作爲標籤屬性輸出,而TH一個id屬性
有沒有人成功地得到這個工作?
謝謝格倫。我開始意識到這一點,但很高興得到證實。 –