我试图在iOS 10上的特定元素上滑动,使用Appum1.6公开删除按钮。
触摸操作和用于滑动左方向的代码在Appum1.4中运行良好,但问题只是在我们迁移到Appum1.6之后才出现。
任何帮助都是非常感谢的。
发布于 2017-02-13 10:56:12
我也有过同样的问题,现在我找到了解决办法。
详细信息:
Appium 1.6.4 beta
Java-Client-5.x beta
应用程序1.6.x已经删除,我们必须创建自己的TouchAction,因为waitAction()使用负值将执行快速滑动操作。例如waitAction(-200)。
TouchAction action1 = new TouchAction(driver).press(x,y).waitAction(-200).moveTo(x_travel, y_travel).release();
action1.perform();
张贴你的反馈。
发布于 2017-02-14 04:31:51
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();
}
}
发布于 2017-02-22 09:59:32
试试这段代码。调用flick_left并传递WebElement。
flick_left(element)
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();
}
https://stackoverflow.com/questions/40904708
复制相似问题