This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.
1 / 5
Feb 2015

If text for an element is not available than scrollTo(xpath) method might be useful.
Just a suggestion.

  • created

    Feb '15
  • last reply

    Feb '15
  • 4

    replies

  • 2.4k

    views

  • 3

    users

  • 3

    likes

Yes I agree there should be some method where we can use xpath and scroll in java client itself. But You can edit and use below code for xpath as a workaround.

**public WebElement scroll(String keyword)
{
HashMap scrollObject = new HashMap();
RemoteWebElement element = (RemoteWebElement) driver.findElementByAndroidUIAutomator(
"new UiSelector().className(\"android.widget.ListView\")");
JavascriptExecutor js = (JavascriptExecutor) driver;
String webElementId = ((RemoteWebElement) element).getId();
System.out.println(webElementId);System.out.println(element);
scrollObject.put("text", keyword);
scrollObject.put("element", webElementId);
js.executeScript("mobile: scrollTo", scrollObject);
return element;
}**

Yup Thanks for the workaround. Will use it. Hope java client comes up with a method soon.
I am using this for now...works fine.
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);" , element);

Very Nice Idea.. @Mayuresh_Shirodkar. because ScrollTo(text) is taking so much of time and also it doesn't support for move to a particular element.. :smile: