Not able to scroll java client 5.0.4 and not able to click element-side menu

Hi Guys ,

Following is my appium spec for Android
Java-client 5.0.4
Appium 1.7.2

Im unable to scroll to the particular element and click on it, want to use generic way of getting the device size and dimension and scroll and not by cordinates have tried below url solutions but not working for me,please can anyone help me out its kinda urgent

For some reason i changed it it was able to scroll but not click on the element but now i am unable to scroll and click,please help

public WebElement scrolltoAccount;

public void verticalScroll()
while(sidemenuobjects.scrolltoAccount.findElements("//android.widget.CheckedTextView[@text=‘My Account’]")).size()==0);
Dimension dimensions = getDriver().manage().window().getSize();
Double screenHeightStart = dimensions.getHeight() * 0.5;
int scrollStart = screenHeightStart.intValue();
Double screenHeightEnd = dimensions.getHeight() * 0.2;
int scrollEnd = screenHeightEnd.intValue();

		new TouchAction(getDriver()).press(0, scrollStart).waitAction()
		.moveTo(0, scrollEnd).release().perform();

	if(getDriver().findElements("//android.widget.CheckedTextView[@text='My Account']")).size()>0)
		getDriver().findElement("//android.widget.CheckedTextView[@text='My Account']")).click();


Please help with exact code to handle this situation,thanks again
if i have to horizontol scroll it how would i doit

@Rathan_G give a try with UiScrollable -> Collect all elements from a list with scroll

Thanks a lot buddy it worked;)
For text it worked but when i use id im getting error because most of the elements has id
getDriver().findElement(MobileBy.AndroidUIAutomator(“new UiScrollable(new UiSelector().resourceIdMatches(“com.test:id/rvDeals”)).scrollIntoView(”
+ “new UiSelector().text(”"+text+""));")) // (in text how can we pass id)

can u suggest for by using id

in official documentation they have given java script executor but is not working
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, String> scrollObject = new HashMap<String, String>();
scrollObject.put(“direction”, “down”);
scrollObject.put(“element”, ((RemoteWebElement) element).getId());
js.executeScript(“mobile: scroll”, scrollObject);
Is JavaScriptExecutor works for Appium? but this is for co-ordinates

For horizontal scroll/swipe i have tried the following but its clicking on the element instead of swipe may be because of the perform action

public void horizontalScroll()
TouchAction action = new TouchAction(getDriver());
int startY = mhpageobjects.swipeWeekenedtreats.getLocation().getY() + (mhpageobjects.swipeWeekenedtreats.getSize().getHeight() / 2);
int startX = mhpageobjects.swipeWeekenedtreats.getLocation().getX() + (mhpageobjects.swipeWeekenedtreats.getSize().getWidth() / 2);

    int endX = mhpageobjects.swipeWeekenedtreats.getLocation().getX() + (mhpageobjects.swipeWeekenedtreats.getSize().getWidth() / 2);
    int endY = mhpageobjects.swipeWeekenedtreats.getLocation().getY() + (mhpageobjects.swipeWeekenedtreats.getSize().getHeight() / 2);, startY).waitAction().moveTo(endX, endY).release().perform();

Can u suggest a way to swipe horizontal it would be of great help

Thanks a lot it worked but for id its giving error

@Rathan_G look here

You need to use resourceid or resourceid matches.

And try to use without package name. Only id itself.

So the last “new UiSelector().text” update to “new UiSelector().resourceId” or matches…

Thanks a lot sir;) any idea to find advanced concepts of appium,their documentation looks weak

Look into java-client code examples at github