Java – “An unknown server-side error occurred while processing the command” while doing scroll down using Appium

androidappiumjava

I have used following code to scroll down

WebElement elementToScroll = driver.findElement(By.id("id"));
scrollDown(elementToScroll, "Max Notifications Per Instance", driver);
((JavascriptExecutor ) driver).executeScript ("mobile: scroll", :direction => 'down');           
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, String> scrollObject = new HashMap<String, String>();
scrollObject.put("direction", "down");
scrollObject.put("element", ((RemoteWebElement) elementToScroll).getId());
scrollObject.put("text", elementToScroll.getText()); 
js.executeScript("mobile: scroll", scrollObject);

and in setup I have changed WebDriver driver into driver = new RemoteWebDriver(); because to hookup my script with sauce lab

Everything is working properly but when I try to do scrolling its giving error

An unknown server-side error occurred while processing the command. (WARNING: The server did not provide any stacktrace information)(..)

Please let me know if I am doing something wrong here.

Best Solution

I have been getting the unknown server-side error while writing automation tests with Appium and it is usually due to an element on the page - like a date picker or autocomplete menu - getting in the way of the element you are trying to click.

Make sure your scroll object is visible and there is nothing overlaying it. You could always use a fluent wait to give any other elements time to finish what they are doing and get out of the way.

Related Question