[英]Appium 1.6 , iOS 10: Swipe left on a specific element
我试图使用Appium 1.6在iOS 10上的特定元素上向左滑动以显示删除按钮。
触摸操作和滑动代码以向左滑动方向适用于appium 1.4,但问题出现在我们迁移到appium 1.6之后。
任何帮助是极大的赞赏
我有同样的问题,现在我找到了解决方案。
细节:
Appium 1.6.4 beta
Java-Client-5.x beta
Appium 1.6.x - Swipe已被删除,我们必须创建自己的TouchAction进行滑动,因为waitAction()使用负值将执行快速滑动操作。 例如waitAction(-200)。
TouchAction action1 = new TouchAction(driver).press(x,y).waitAction(-200).moveTo(x_travel, y_travel).release();
action1.perform();
发表您的反馈。
public void swipe(String direction, int offset, int time) {
int y = appiumDriver.manage().window().getSize().getHeight();
int x = appiumDriver.manage().window().getSize().getWidth();
TouchAction touchAction = new TouchAction(appiumDriver);
System.out.println(x+" "+y);
System.out.println("Entering swipe");
if("right".equalsIgnoreCase(direction))
{
System.out.println("Swipe Right");
touchAction.press(x-offset, y/2).moveTo(-(x-(2*offset)), 0).release().perform();
}else if("left".equalsIgnoreCase(direction)){
System.out.println("Swipe Left");
touchAction.press(offset, y/2).moveTo((x-(2*offset)), 0).release().perform();
}else if("up".equalsIgnoreCase(direction)){
System.out.println("Swipe Up");
touchAction.press(x/2, offset).moveTo(0, y-(2*offset)).release().perform();
}else if("down".equalsIgnoreCase(direction)){
System.out.println("Swipe Down");
touchAction.press(x/2, y-offset).moveTo(0, -(y-(2*offset))).release().perform();
}
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
试试这个代码。 调用flick_left并传递WebElement。
flick_left(元件)
public void flick_left(WebElement flick_element) {
Point location = flick_element.getLocation();
Dimension size = flick_element.getSize();
int flick_x, flick_y, flick_start_x, flick_end_x,flick_start_y,flick_end_y;
flick_x =size.getWidth();
flick_y = location.y + (size.getHeight()/2);
flick_start_x = flick_x - (int)((double)flick_x*0.25);
flick_end_x = flick_x -(int)((double)flick_x*0.55);
swipe(flick_start_x, flick_y, flick_end_x, flick_y,-200);
}
public void swipe(int swipe_start_x, int swipe_start_y, int swipe_end_x, int swipe_end_y,int duration){
int x = swipe_start_x;
int y = swipe_start_y;
int x_travel = swipe_end_x-swipe_start_x;
int y_travel = swipe_end_y-swipe_start_y;
TouchAction action1 = new TouchAction(driver).press(x,y).waitAction(duration).moveTo(x_travel, y_travel).release();
action1.perform();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.