Appium MobileElement 滑动返回未知服务器错误 [英] Appium MobileElement swipe returns unknown server error
本文介绍了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屋!
查看全文