我有一个想要允许来自设备事件的联系人的应用。我用了
(autoAlertAccept
,是的)但这不会对我有用。我正在使用 appium 1.5.2 和
即使我想刷这个特定的联系人聊天或打电话
特别的联系。当我使用:
driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
driver.findElement(By.className("android.widget.ImageButton")).click();
size1 = driver.manage().window().getSize();
System.out.println(size1); int x1 = (int) (size1.width * 0.70);
int x2 = (int) (size1.width * 0.30);
int starty =size1.height / 2;
System.out.println(x1 + x2 + starty);
driver.findElement(By.name("Demo Usr"));
driver.swipe(x1,starty,x2,starty,3000);
我发现了一些异常
答案 0 :(得分:0)
您提供的代码将从左向右滑动屏幕。但是要将元素从一个位置移动到另一个位置,请使用以下代码:
WebElement elem = driver.findElement(By.xpath("ur xpath"));//get element locator as ur wish by accesibility id or xpath.
int startX = elem.getLocation().getX();
int startY = elem.getLocation().getY();
//this will swipe from right to left horizontally
driver.swipe(startX,startY,startX-90,startY,2000);
// use 90 or more according to ur screen position
//this will swipe from left to right horizontally
driver.swipe(startX,startY,startX+90,startY,2000);
//u must have to be sure that this location is within the screen, otherwise u will get an error
如果有任何问题,请告诉我。