0

I was using the following code to scroll to an element which is not visible:

WebElement element = driver.findElementByName("text");

        JavascriptExecutor js = (JavascriptExecutor) driver;
        HashMap<String, String> scrollObjects = new HashMap<String, String>();
        scrollObjects.put("element", ((RemoteWebElement) element).getId());
        js.executeScript("mobile: scrollTo", scrollObjects);

I am getting below error when I use above method for scrolling:-

Unknown command, all the mobile commands except scroll have been removed.

In Appium 1.5.0 , name locator is removed

In java-client v4.0.0, scrollTo() and scrollToExact() became deprecated.

I am using xpath instead of findElementByName().

What is the workaround for mobile: scrollTo

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Galet
  • 5,853
  • 21
  • 82
  • 148
  • have you tried to make the element visible by drive.swipe() method or using move to element location? – noor Aug 03 '16 at 14:31

1 Answers1

0

I have found answer for this issue. Use element and direction as arguments to scroll method.

WebElement element = driver.findElementByName("text");

JavascriptExecutor js = (JavascriptExecutor) driver;

HashMap scrollObjects = new HashMap();
scrollObjects.put("element", ((RemoteWebElement) element).getId());
scrollObjects.put("direction", "down");
driver.executeScript("mobile: scroll", scrollObjects );

References:- https://pioneer2k9.blogspot.in/2016/08/mobile-scroll-command-is-not-working-in_4.html

Galet
  • 5,853
  • 21
  • 82
  • 148