Appium Swipe 问题报错求解?

ben · 2014年06月04日 · 最后由 扮猪吃老虎 回复于 2015年05月06日 · 1339 次阅读

Appium 1.1 版本
Windows/Mac

求解奇怪的问题,用 swipe 操作屏幕滑动报错。。然后换了一台手机跑 Demo 的 AndroidContactsTest 用 swipe 可以。另外的 APK 滑动就报错。selendroid 不能操作滑动么?

debug: Appium request initiated at /wd/hub/session/b2c62fc5-9594-f99b-ffac-a8e7c24ebee5/touc
h/perform
debug: Request received with params: {"actions":[{"action":"press","options":{"y":1500,"x":2
00}},{"action":"wait","options":{"ms":200}},{"action":"moveTo","options":{"y":700,"x":200}},
{"action":"release","options":{}}]}
debug: Proxying command to localhost:8080
info: Making http request with opts: {"url":"http://localhost:8080/wd/hub/session/b2c62fc5-9
594-f99b-ffac-a8e7c24ebee5/touch/perform","method":"POST","json":{"actions":[{"action":"pres
s","options":{"y":1500,"x":200}},{"action":"wait","options":{"ms":200}},{"action":"moveTo","
options":{"y":700,"x":200}},{"action":"release","options":{}}]}}
debug: Proxied response received with status 500: undefined
POST /wd/hub/session/b2c62fc5-9594-f99b-ffac-a8e7c24ebee5/touch/perform 500 45ms
debug: Appium request initiated at /wd/hub/session/b2c62fc5-9594-f99b-ffac-a8e7c24ebee5
debug: Request received with params: {}
info: Shutting down appium session...
info: Stopping selendroid server
共收到 14 条回复 时间 点赞

贴一下 swipe 部分的代码吧

ben #2 · 2014年06月05日 Author

#1 楼 @xiaomayi0323
配置是 Selendroid。。swipe 基本没有什么,就是欢迎界面滑动。

capabilities.setCapability("automationName","Selendroid");
   capabilities.setCapability("platformName","Android");

@Test
public void login(){
    sleep(3000);
    driver.findElementById("rl_weizhang").click();
    driver.findElementById("cede_text_new").click();
   List<WebElement> content=driver.findElementsById("break_rule_list_content");
    for(int i=0;i<content.size();i++){
        System.out.println(content.get(i).getText()+"  "+content.get(i).getLocation());
    }
    sleep(3000);
    driver.swipe(200, 800, 200,300, 200);
}

#2 楼 @benlooking duration 值设大一点试试,比如 600

ben #4 · 2014年06月06日 Author

#3 楼 @xiaomayi0323 应该不是时间的问题。设大了还是报

debug: Proxied response received with status 500: undefined
POST /wd/hub/session/b2c62fc5-9594-f99b-ffac-a8e7c24ebee5/touch/perform 500 45ms
info: [SELENDROID] replyWithServerError 500 

应该是最后去执行 perform 的时候报的错。。

ben #5 · 2014年06月08日 Author

#3 楼 @xiaomayi0323 我试了换成 1.0 版本以下的 RemoteWebDriver 的那种形式,滑动是 ok 的。。

#4 楼 @benlooking 设置超过 2000 试试

java 客户端么,在 4.4 系统以下,现在确实有这个问题,很奇怪,老美没有回复我

ben #8 · 2014年06月09日 Author

#7 楼 @bxc168 恩。。现在滑动都有这个问题。应该是 perform 的时候出的问题。

ben #6 · 2014年06月09日 Author

#6 楼 @seveniruby 应该不是时间的问题。

@benlooking
bootstraponline commented an hour ago
appium >= 1.0 has changed the api. For selendroid, you need to use their api.

老美说要另外单独用 selendroid 去实现低版本的 AOS 系统,但是我还不确定他们是不是会修复这个问题

jlipps commented 6 hours ago
Please raise this issue at the selendroid project's issue tracker.

appium 的大哥说要去 selendroid project 提 issue

楼主看下这个方法行的通不?
https://github.com/appium/java-client/issues/143

def swipe(self,startx,starty,endx,endy,duration):
    '''
    startx和starty为起点坐标,endx和endy为终点坐标,duration为滑动时间,单位ms
    agent:
    self.swipe(1079,1919,1079,1,4000)
    '''
    os.popen("adb shell input touchscreen swipe "+ str(startx) + " " + str(starty) + " " + str(endx) + " " + str(endy) + " " + str(duration))

driver 的 swip 方法在 selendroid 模式下只对 4.4 以上设备有效

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