Scrolling issue in appium

Hi Everyone

I am using appium 1.7.2 and i am trying to scroll to particular text and then click the specified text when it is found but in my code it is scrolling till the bottom and after that nothing happens

Can anyone please help me with it


MobileElement element = (MobileElement) driver.findElement(MobileBy.AndroidUIAutomator(
“new UiScrollable(new UiSelector().className(“android.view.View”)).scrollIntoView(”
+ “new UiSelector().text(”+20+"));"));;

first method - m using this method to get into middle of the form , if there is no static text and content desc given to the element i want to click then i call the normal method to click …

                                                  try {
							TouchAction action = new TouchAction(driver);
							PointOption p1= new PointOption();
							Dimension dimensions = driver.manage().window().getSize();
							Double screenHeightStart = dimensions.getHeight() * 0.5;
							int h1 = screenHeightStart.intValue();
							Double screenHeightEnd = dimensions.getHeight() * 0.2;
							int h2 = screenHeightEnd.intValue();, h1)).moveTo(p1.point(0,-h2)).release().perform();
						      } catch (Exception e) {
							 System.out.println("scroll not done");
						long timeoutInSeconds56 = 200;
						new WebDriverWait(driver, timeoutInSeconds56).until(ExpectedConditions.visibilityOfElementLocated(
						System.out.println("clicked on the first product");       

second method - this method i use to reach at the end of form - flingToEnd(1) - the int will decide how many time you want “fling” action to happen

driver.findElement(MobileBy.AndroidUIAutomator(“new UiScrollable(new UiSelector().scrollable(true).instance(0)).flingToEnd(1)”));;

there are some more methods if you wanna check out then -

The second method works for me thank you