Appium MobileElement滑动返回未知服务器错误 [英] Appium MobileElement swipe returns unknown server error

查看:97
本文介绍了Appium MobileElement滑动返回未知服务器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试滑动MobileElement,但是它给服务器端带来了错误.这可能是什么原因?

I am trying to swipe MobileElement but its giving server-side error. What may be the cause here?

代码:

 MobileElement mb= (MobileElement)driver1.findElement(By.xpath("//android.widget.ListView[@index='0'][@resource-id='android:id/list']"));

 mb.swipe(SwipeElementDirection.LEFT, 1000);

错误:

org.openqa.selenium.WebDriverException:服务器端未知错误 在处理命令时发生. (警告:服务器未 提供任何堆栈跟踪信息)命令持续时间或超时:16 毫秒

org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 16 milliseconds

推荐答案

您可以尝试使用以下代码对所有移动设备进行动态滑动:

Dimension dimension = driver.manage().window().getSize();
int width = dimension.getWidth();
int height = dimension.getHeight();
switch(direction) {
    case "right":
        driver.swipe((int) (width*(0.20)), (int) (height*(0.50)), (int)(width*(0.80)), (int) (height*(0.50)), 6000);
    break;
    case "left":
        driver.swipe((int) (width*(0.80)), (int) (height*(0.50)), (int) (width*(0.20)), (int) (height*(0.50)), 6000);
    break;
    case "up":
        driver.swipe((int) (width*(0.50)), (int) (height*(0.70)), (int) (width*(0.50)), (int) (height*(0.30)), 6000);
    break;
    default:
        driver.swipe((int) (width*(0.50)), (int) (height*(0.30)), (int) (width*(0.50)), (int) (height*(0.70)), 6000);
    break;
}

这篇关于Appium MobileElement滑动返回未知服务器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆