1
내 UI는 사용자 지정 컨트롤을 사용하여 예/아니요 스위치를 나타냅니다. UI 테스트에서 화면의 컨트롤 반복마다 예 또는 아니요를 탭 할 수 있지만 AutomationID를 쿼리하면 첫 번째 결과가 표시됩니다. 특정 사용자 정의 컨트롤의 하위 버튼에 어떻게 액세스합니까? 내가 탭할 항목은 SwitchLPRrec의 ButtonNo/ButtonYes 및 SwitchTowDolly의 ButtonNo/ButtonYes입니다.Xamarin.UITest 사용자 지정 컨트롤의 자식 하위 요소 동일한 AutomationID가있는 자식 요소
사용자 정의 스위치
public RC_Switch_YesNo()
{
try
{
this.HorizontalOptions = LayoutOptions.Center;
this.VerticalOptions = LayoutOptions.Center;
negative = new Button();
negative.Text = "No";
negative.AutomationId = "ButtonNo";
negative.Style = AppStyling.Style_Button_Switch;
negative.Clicked += (o, s) => OnSelectedItemChanged(this, ItemSelected, (int)Enums_RecoveryConnect.SelectionStatus.SelectionFalse);
positive = new Button();
positive.Text = "Yes";
positive.AutomationId = "ButtonYes";
positive.Style = AppStyling.Style_Button_Switch;
positive.Clicked += (o, s) => OnSelectedItemChanged(this, ItemSelected, (int)Enums_RecoveryConnect.SelectionStatus.SelectionTrue);
if(Device.Idiom == TargetIdiom.Tablet)
{
negative.HeightRequest = (int)AppStyling.TabletEntry.TabletHeight;
positive.HeightRequest = (int)AppStyling.TabletEntry.TabletHeight;
negative.FontSize = (int)AppStyling.TabletEntry.TabletEntryTextSize;
positive.FontSize = (int)AppStyling.TabletEntry.TabletEntryTextSize;
}
this.Children.Add(negative, 0,0);
this.Children.Add(positive, 1,0);
}
catch(System.Exception ex)
{
Helpers.Helper_ErrorHandling.SendErrorToServer(ex);
}
}
REPL 화면