'Getting WebDriverException: Message: Unhandled endpoint when executing script with scroll or swipe keywords (Appium library) on iOS real device
I'm using Robot Framework with Appium Library for test scripts for native iOS application on Real Device.
I need to scroll down (or up) to certain elements on the screen that aren't visible into view, but when I'm using the keywords scroll, scroll down, scroll up with appropriate element locators, or swipe and swipe by percent, I'm getting the same error when executing the script:
WebDriverException: Message: Unhandled endpoint: /session/[SESSION ID]/execute -- http://[IP]:8100/ with parameters { wildcards = ( "session/[SESSION ID]/execute" ); }
Additionally I tried by using javascript, but without success i.e. the same error appears:
Execute Script driver.execute('mobile: scroll', {direction: 'down'});
Does anyone have an idea what causes this problem and how to solve it?
Solution 1:[1]
You can try this function:
This work for me handle swipe for iOS application: I'm using appium 1.21.0
public void swipeScreen(String direction) {
int deviceWidth = getDriver().manage().window().getSize().getWidth();
int deviceHeight = getDriver().manage().window().getSize().getHeight();
int midX = (deviceWidth / 2);
int midY = (deviceHeight / 2);
int bottomEdge = (int) (deviceHeight * 0.85f);
Dimension size = getDriver().manage().window().getSize();
int y0 = (int)((double)size.height * 0.7D);
int y1 = (int)((double)size.height * 0.3D);
switch (direction.toUpperCase()) {
case "DOWN":
new TouchAction(getDriver())
.press(PointOption.point(midX, midY))
.waitAction(WaitOptions.waitOptions(Duration.ofMillis(1000)))
.moveTo(PointOption.point(midX, bottomEdge))
.release()
.perform();
waitABit(2);
break;
case "UP":
new TouchAction(getDriver())
.press((new PointOption()).withCoordinates(midX, y0))
.waitAction(WaitOptions.waitOptions(Duration.ofMillis(1000)))
.moveTo((new PointOption()).withCoordinates(midX, y1))
.release()
.perform();
break;
default:
throw new IllegalStateException("Unexpected value: " + direction.toUpperCase());
}
}
public void swipeUpScreenToElement(By element) {
for(int i = 0; i < getExplicitTimeout(); ++i) {
if (!isPresent(element)) {
swipeScreen("UP");
}
}
}
public void swipeDownScreenToElement(By element, int swipeCount) {
for(int i = 0; i < getExplicitTimeout(); ++i) {
if (!isPresent(element)) {
swipeScreen("DOWN");
}
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Fransiskus Andika Setiawan |
