java-client: 5.0.4
selenium: 3.11.0
I tried using JS to scroll to specified element. But it just passes that function, doesn’t scroll at all.
Same function without element
, it scrolls well, just can’t find specified element.
public static void swipeToElementByJS(AppiumDriver driver, Direction direction, MobileElement element) {
JavascriptExecutor js = driver;
HashMap<String, String> scrollObject = new HashMap<>();
scrollObject.put("direction", direction.toString());
scrollObject.put("element", element.getId());
js.executeScript("mobile: swipe", scrollObject);
}
This is run logs
[JSONWP Proxy] Proxying [POST /element] to [POST http://localhost:8100/session/4257CCEB-3711-461A-B64B-741B81907FE5/element] with body: {“using”:“xpath”,“value”:“(//XCUIElementTypeOther[@name=‘普通’])[3]”}
[JSONWP Proxy] Got response with status 200: {“value”:{“ELEMENT”:“3BBEB7A8-5DA7-466D-9D4F-A6ACD35F56B4”},“sessionId”:“4257CCEB-3711-461A-B64B-741B81907FE5”,“status”:0}
[MJSONWP] Responding to client with driver.findElement() result: {“ELEMENT”:“3BBEB7A8-5DA7-466D-9D4F-A6ACD35F56B4”}
[HTTP] ← POST /wd/hub/session/77796feb-c0b4-4128-be4b-c8da69d6e32a/element 200 13097 ms - 122
[HTTP] → POST /wd/hub/session/77796feb-c0b4-4128-be4b-c8da69d6e32a/execute {“script”:“mobile: swipe”,“args”:[{“direction”:“up”,“element”:“3BBEB7A8-5DA7-466D-9D4F-A6ACD35F56B4”}]}
[MJSONWP] Calling AppiumDriver.execute() with args: [“mobile: swipe”,[{“direction”:“up”,“element”:“3BBEB7A8-5DA7-466D-9D4F-A6ACD35F56B4”}],“77796feb-c0b4-4128-be4b-c8da69d6e32a”]
Someone has any idea. Thanks a lot (bow)