0

我有一个应用程序想要允许来自设备事件的联系人。我用过 ( autoAlertAccept,true) 但这对我不起作用。我正在使用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);

我发现了一些异常

4

1 回答 1

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

如果有任何问题,请告诉我。

于 2016-05-30T08:48:07.547 回答