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);
> [36minfo[39m: Pushing command to appium work queue relementscrollTo.
rtext”:null:direction”:”down:elemenilcr:”51]
> ERROR: [9Orndebug[39m: Appium request initiated at /wd/hublsessionlO74be83f-c086--488b-
922-7e544b7d3be2/execute
> ERROR: [9Orndebug[39m: Request received with params: Çargs’:
[{“elernent”:”5,direction”:down],Mscript”:”mobile: scrol ITo”)
> [36minfo[39m: [BOOTSTRAP] [info] Cot data from client
> [36minfo[39m: [BOOTSTRAP] [info] Cot command of type ACTION
> [36minfo[39m: [BOOTSTRAP] [debug] Cot command action: scrollTo
> [36minfo[39m: [BOOTSTRAP] [info] Returning result rvalue:Could not scroll element into view:
null”statuC:13)
> [36m info[39m: Responding to client with error rstatus”:13,”valueTmessage:An unknown server-
side error occurred while processing the command.”origValu&:”Could not scroll element into view:
> POST /wd/hub/sessionfO74be83f-c086-488b-a922-7e544b7d3be2/execute 500 7574ms - 237b
> [36m info[39m: Didn’t get a new command in 60 secs, shutting down...
MobileElement element = (MobileElement) DeviceWrapper.getAppiumDriver().findElementByClassName(locator);
JavascriptExecutor js = (JavascriptExecutor) DeviceWrapper.getAppiumDriver();
HashMap<String, String> scrollObject = new HashMap<String, String>();
scrollObject.put("direction", "down");
scrollObject.put("element", ((RemoteWebElement) element).getId());
scrollObject.put("text", text);
js.executeScript("mobile: scrollTo", scrollObject);And here is the code from the Controller.js file that it's actually calling.
exports.mobileScrollTo = function (req, res) {
logCustomDeprecationWarning('mobile method', 'scrollTo',
"scrollTo will be removed in a future version of appium");
req.body = _.defaults(req.body, {
element: null
, text: null
, direction: "vertical"
});
var element = req.body.element
, text = req.body.text
, direction = req.body.direction;
req.device.scrollTo(element, text, direction, getResponseHandler(req, res));
};