How to fix 'Could not proxy command to remote server. Original error: Error: socket hang up' issue when scrolling in appium?

Viewed 4594

I tried to scroll iOS application using appium, this error occurs as when the scroll finishes.

I use a real iOS device as an emulator. appium v1.13 java client v6.1.0

Code for scroll:

JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, String> swipeObject = new 
HashMap<String, String>();

swipeObject.put("direction", "up"); // up for swipe
js.executeScript("mobile: scroll", swipeObject);

Full error message:

Encountered internal error running command: UnknownError: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to remote server. Original error: Error: socket hang up

After the scrolling all the way to the bottom, one button needs to be clicked. but this scrolls all the way to the bottom and exit with this error.

1 Answers

you may trap this exception in a try catch block :

try{
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, String> swipeObject = new 
HashMap<String, String>();

swipeObject.put("direction", "up"); // up for swipe
js.executeScript("mobile: scroll", swipeObject);
}catch(exception e)
{
}

button.click() ;

This way the exception happens but your test will continue without failing your execution.

Related