Xamarin UI Test (1.0.0) を使用しています。選択した日付を更新する拡張メソッドを作成しようとしています。ここまで書いてきた内容です。iOS および Android 4.x で動作します。Android 5.x では動作しません。
public static void EnterDate(this IApp app, string datePickerStyleId, DateTime date)
{
var array = app.Query(datePickerStyleId);
if (array.Length == 0)
return;
foreach (var picker in array)
{
var newMonth = date.ToString("MMM");
var newDay = date.Day.ToString();
var newYear = date.Year.ToString();
if (app.IsAndroid())
{
app.Tap(picker.Label);
//if device OS > 5 try scrolll up
app.Repl();
app.Screenshot("Date Picker");
app.Tap("month");
app.EnterText(newMonth);
app.PressEnter();
app.Tap("day");
app.EnterText(newDay);
app.PressEnter();
app.Tap("year");
app.EnterText(newYear);
app.PressEnter();
app.ClickDone();
app.Screenshot("Page After Changing Date");
app.ClickButton("Ok");
}
else if (app.IsIOS())
{
app.Tap(picker.Id);
app.Screenshot("Date Picker");
var currentDate = picker.Text;
var split = currentDate.Split(' ');
var currentMonth = split[0];
var currentDay = split[1].Remove(split[1].Length - 1);
var currentYear = split[2];
if (!newMonth.Equals(currentMonth))
{
app.Tap(newMonth);
}
if (!newDay.Equals(currentDay))
{
app.Tap(newDay);
}
if (!newYear.Equals(currentYear))
{
app.Tap(newYear);
}
app.ClickButton("Done");
}
}
}
私が直面している問題は、特定の日付を選択する方法がわからないことです。App.ScrollUp()/.ScrollDown() は、別の月に移動するために機能します。ただし、現在の月を特定してから日を選択することはできませんでした。以下は、Repl() ツールのツリー コマンドからの出力です。
tree [[object CalabashRootView] > ... > FrameLayout] [FrameLayout] id: "content" [LinearLayout] id: "parentPanel" [FrameLayout] id: "customPanel" [FrameLayout] id: "custom" [DatePicker > LinearLayout] id: "datePicker" [LinearLayout] id: "day_picker_selector_layout"
[TextView] id: "date_picker_header" text: "Thursday" [LinearLayout] id: "date_picker_month_day_year_layout" [LinearLayout] id: "date_picker_month_and_day_layout", label: "8 月 6 日" [TextView] id: "date_picker_month" text: "AUG" [ TextView] id: "date_picker_day" text: "6" [TextView] id: "date_picker_year" text: "2015" [AccessibleDateAnimator > ... > SimpleMonthView] id: "animator", label: "月グリッド: 8 月 6 日" [LinearLayout] id: "buttonPanel" [ボタン] id: "button2" text: "キャンセル"[ボタン] id: "button1" テキスト: "OK"
iOS および Android (4.x および 5.x) で動作する Xamarin UI テストの日付を選択する方法を知っている人はいますか?