Xamarin UI 测试 [AlertDialog]

Xamarin UI Test [AlertDialog]

是否可以在UITest中查询、点击按钮、获取AlertDialog的消息内容?我试过了this solution I can seem to query the AlertDialog itself
但是每当我尝试查询 OK 或 id message 时,我似乎无法检索它或者它会给出很多结果,例如像这样:

还有其他方法可以让我查询 AlertDialog 内容吗?谢谢!

您的第一个查询 returns AlertDialogLayout,您正在寻找 AlertDialogLayout 内的 TextView。 您应该尝试寻找 AlertDialogLayout 的 descendants

如果您知道要查找的文本,最简单的查找方法是

app.Query(x => x.Class("AlertDialogLayout").Descendant().Text("YOUR TEXT"))