Appium [已解决]请教一个问题 :Tried to execute non-existent mobile command 'swipe'

王先生 · 2015年01月10日 · 最后由 王先生 回复于 2015年01月12日 · 1589 次阅读

错误信息如下:
Tried to execute non-existent mobile command 'swipe'. Most mobile commands have been ported to official client library methods. Please check your Appium library for more information and documentation

环境信息如下:
appium:AppiumForWindows-1.0.0.3
java-client.jar(1.3.0 版本)
安卓版本(采用的虚拟机 4.4.2)
JDK 版本为:1.6

开发环境(目前引用的 3 个包):
java-client-1.3.0.jar
selenium-java-2.44.0.jar
selenium-server-standalone-2.44.0.jar

测试中需要模拟滑动效果,仿照着网上写了如下代码:
private static void screenmoveright(){
//其中的 webdriver 使用的是 AppiumDriver
//AppiumDriver driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
System.out.println("执行拖动方法...");

try {
JavascriptExecutor js =(JavascriptExecutor) driver;
HashMap swipeObject = new HashMap();
swipeObject.put("startX", 260.00);
swipeObject.put("startY", 25.00);
swipeObject.put("endX", 3.00);
swipeObject.put("endY", 25.00);
swipeObject.put("duration", 1000.00);
js.executeScript("mobile:swipe", swipeObject);
} catch (WebDriverException ex) {
ex.printStackTrace();
}
System.out.println("执行拖动方法结束...");
}

目前一执行该方法进行滑动的时候,就报如下的错误:
info: [debug] Appium session started with sessionId 766660cc-2416-4f93-8a34-98c92b6fac6b

info: <-- POST /wd/hub/session 303 31669.348 ms - 9
info: --> GET /wd/hub/session/766660cc-2416-4f93-8a34-98c92b6fac6b {}
info: [debug] Responding to client with success: {"status":0,"value":{"platform":"LINUX","browserName":"","platformVersion":"4.4","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"app":"D:\workspace\appdemo\apps\MobileTest.apk","platformVersion":"4.4","deviceName":"Android Emulator","platformName":"Android","browserName":""},"app":"D:\workspace\appdemo\apps\MobileTest.apk","deviceName":"Android Emulator","platformName":"Android"},"sessionId":"766660cc-2416-4f93-8a34-98c92b6fac6b"}
info: <-- GET /wd/hub/session/766660cc-2416-4f93-8a34-98c92b6fac6b 200 1.297 ms - 585 {"status":0,"value":{"platform":"LINUX","browserName":"","platformVersion":"4.4","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"app":"D:\workspace\appdemo\apps\MobileTest.apk","platformVersion":"4.4","deviceName":"Android Emulator","platformName":"Android","browserName":""},"app":"D:\workspace\appdemo\apps\MobileTest.apk","deviceName":"Android Emulator","platformName":"Android"},"sessionId":"766660cc-2416-4f93-8a34-98c92b6fac6b"}
info: --> POST /wd/hub/session/766660cc-2416-4f93-8a34-98c92b6fac6b/execute {"script":"mobile: swipe","args":[{"startX":10,"duration":1,"startY":5,"endX":3,"endY":5}]}
info: [debug] Tried to execute non-existent mobile command 'swipe'. Most mobile commands have been ported to official client library methods. Please check your Appium library for more information and documentation
info: [debug] Responding to client that a method is not implemented

共收到 2 条回复 时间 点赞

大概知道问题的原因了,可是看不懂 js 代码啊!

结贴:
问题终于搞定,看来想要提高还是要知道 appium 的运行原理,根据原理看源代码。目前判断应该是版本问题。但是滑动效果我不用 mobile:swipe,而改用 mobile: flick,因为我看了 js 中的代码,我的版本中没有提供 mobile:swipe,不知道 1.3.4 是否提供了改种方式,需要我升级后验证!

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册