How can we add wait in AndroidUIAutomator script in appium?

I am trying to automate a scenario where there are some cards that are visible after horizontal scroll. Each card has an accessibility Id equal to cardholder name and at a time only one card is viewable. I am using below script to scroll to the specific card

                    .located(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector().scrollable(true).instance(1))" +
                            ".setAsHorizontalList()" +
                            ".scrollIntoView(new UiSelector().description(\"abc\"))")))

but there is a problem. Whenever there is a scroll, an API call is made which takes sometime to load the card data. Above script works perfectly regarding scroll but doesn’t stop when the said card is reached. I suppose this problem is due to the reason that it takes sometime for data to load but the script can’t handle the wait. Hence, it assumes the card is not present. Is there any way we can add wait to AndroidUIAutomator script?

Appium has built in implicit waits that you can use. Spec and code examples here:

I tried it but its not working

maybe your search condition not correct

I am using content-desc of card which is similar to card_holder name so If the cardholder name is abc then its content-desc will also be abc

is it text inside card? can you share it page source piece?

in general: UiScrollable + UiScrollable are pure Android native commands. We cant fix here anything only double check that we use it correctly.

This is the image of the card
and this is the locator

Ignore the abc text. Let’s do it with Hello World

looks everything correct. not sure about only ‘instance(1)’ - this is second scrollable on your screen. if it has any id you can change it to ‘resourceIdMatches’.

on your place i will try next:

  1. try ’ scrollDescriptionIntoView(String text)’
  2. nothing helps -> scroll manually and check that needed element found.