Swipe horizontally to a particular element

I’m facing scenario where I have a set of elements that will move horizontally and on which I need to perform swipe until a particular element and click it. As far I checked the web I couldn’t find an exact solution for my case.

I have used:
public static void swipeToTextClick(AndroidDriver driver, String text){
MobileElement el = (MobileElement) driver.findElementByAndroidUIAutomator(“new UiScrollable(new UiSelector()).setAsHorizontalList().scrollIntoView(”
+ “new UiSelector().text(”"+text+""));");
el.click();
}
But the swipe is failing. I would like to know any other method that I can use to perform the kind of swipe that I need now, thanks in advance

  1. Does swipe start?
  2. Do you have several list objects on screen that you can swipe?
  3. Try workarounds mentioned here http://appium.io/docs/en/writing-running-appium/tutorial/swipe-tutorial/
  1. No the swipe doesn’t start at all when I used the above mentioned method.
  2. Yeah there are several list objects(different banks) on screen of which I want to swipe until particular element(until a particular bank that I want to chose), so that it will be in the view and then I can perform different actions on it.
  3. None of the work arounds suits my scenario. I tried most of it, I have a method for swiping but that is only for generic swipe where it just swipes without condition, I need a controlled swipe until I see a particular element.

Thanks Aleksei for your reply, appreciate it.

These are also other ways to perform a swipe. Check https://www.youtube.com/watch?v=oAJ7jwMNFVU

With several swipes you need to specify what exactly list needs to swipe. In your current code it swipes first one.