Home > Mobile >  Xamarin.UITest RecyclerView wait for items to load
Xamarin.UITest RecyclerView wait for items to load

Time:01-18

I am trying to write an Xamarin.UITest for my Android project. My app has a "download" UIButton, that when pressed, downloads data and then populates a RecyclerView. Then when a "clear" UIButton is pressed, the RecyclerView is cleared. This is what I tried so far:

app.Tap(c => c.Marked("download_btn"));
app.WaitForElement(x => x.Marked("recycler_item"), "Timed out waiting for items to load", TimeSpan.FromSeconds(5));
app.Tap(c => c.Marked("clear_btn"));

The app.WaitForElement part never finds the items in the RecyclerView, even when they are there. I want to test that there is at least 1 item in the RecyclerView after I tap the download button.

CodePudding user response:

I figured out how to wait for the RecyclerView to load. You can wait for a view that is inside the layout of item itself, such as a TextView:

app.WaitForElement(x => x.Marked("name_textView"), "Timed out waiting for items to load", TimeSpan.FromSeconds(3));
  • Related