This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.
7 / 7
Apr 2018

Hi Guys ,

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

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

@FindBy(id=“com.licious:id/nav_view”)
public WebElement scrolltoAccount;

public void verticalScroll()
{
while(sidemenuobjects.scrolltoAccount.findElements(By.id("//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(By.id("//android.widget.CheckedTextView[@text='My Account']")).size()>0)
	{
		getDriver().findElement(By.id("//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

  • created

    Apr '18
  • last reply

    Apr '18
  • 6

    replies

  • 702

    views

  • 2

    users

  • 6

    links

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);
https://discuss.appium.io/t/is-javascriptexecutor-works-for-appium/3597/84 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);

    action.press(startX, startY).waitAction().moveTo(endX, endY).release().perform();
}

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

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