无法使用Android Xamarin Forms UITest点击DisplayAlert按钮



我正在使用Xamarin UITest来执行UI单元测试。我不知道如何让UITest框架点击DisplayAlert(…(按钮。

// this query finds the YES button on the Alert
app.WaitForElement( c => c.Marked( "YES" ).Parent().Class( "AlertDialogLayout" ), "ERR", TimeSpan.FromSeconds( 1 ) );
// but tap with the same query doesn't click it
app.Tap( c => c.Marked( "YES" ).Parent().Class( "AlertDialogLayout" ) );

令人惊讶的是,至少对我来说,应用程序。Tap((不需要也不接受查询来查找该应用程序的任何弹出按钮。WaitForElement((会。以下工作:

// this query finds the YES button on the Alert
app.WaitForElement( c => c.Marked( "YES" ).Parent().Class( "AlertDialogLayout" ), "ERR", TimeSpan.FromSeconds( 1 ) );
// but tap with the same query doesn't click it
// but "YES" does!
app.Tap( "YES" ); 

最新更新