Xamarin UITest:如何在Android上的NumberPicker中选择字符串

时间:2018-06-06 04:32:29

标签: xamarin.uitest

我们的应用在所有字符串值的不同位置都有NumberPickers。我想使用字符串值而不是整数值来选择值。任何帮助是极大的赞赏。

我试过了 app.Query(x => x.Class(" EditText")。Invoke(" setText"," cat")); 它实际上设置了文本,但是在保存值时它会恢复为原始选择。

我不想使用以下代码,因为它使用整数值设置值。 app.Query(x => x.Class(" NumberPicker")。调用(" setValue",2)) 如果有人可以帮助我使用字符串值选择NumberPicker中的值,那将是很好的。

1 个答案:

答案 0 :(得分:0)

打开数字选择器后,在Android上,您可以使用以下代码使用字符串值(例如,使用Xamarin Forms Gallery应用程序)选择NumberPicker值:

app.ScrollDownTo(m => m.Text("White"), x => x.Id("select_dialog_listview"));
app.Tap(x => x.Text("White"));
Assert.IsTrue(app.Query("PickerControl")[0].Text == "White");