Appium vision:1.0.0-beta.2,官网下载 scroll_to 方法报错
请问大家用的什么版本?报错吗?能否降级?这样就不会有这么多奇怪的问题。
public WebElement scroll_to(String text) {
RemoteWebElement element = null;
try {
text = text.replaceAll("\"", "\\\""); // quotes must be escaped.
final String jsonString = "{\"script\":\"mobile: find\",\"args\":[[\"scroll\",[[3,\""
+ text + "\"]],[[7,\"" + text + "\"]]]]}";
final String id = driver.getSessionId().toString();
final String executeURL = url + "/session/" + id + "/execute";
final HttpPost post = new HttpPost(executeURL);
post.setEntity(new StringEntity(jsonString, "UTF8"));
post.setHeader("Content-type", "application/json");
final HttpEntity responseEntity = client.execute(post).getEntity();
if (responseEntity != null) {
try {
final String responseString = EntityUtils.toString(responseEntity);
// {"status":0,"value":{"ELEMENT":"1"},"sessionId":"8e982755-980f-4036-b3d1-c0e14e890273"}
final String elementId = parser.parse(responseString)
.getAsJsonObject().get("value").getAsJsonObject().get("ELEMENT")
.getAsString();
element = newElement(elementId);
} catch (final Exception e) {
e.printStackTrace();
} finally {
EntityUtils.consume(responseEntity);
}
}
} catch (final Exception e) {
e.printStackTrace();
}
return element;
}