appium java 高版本 实现上下滑动

    @Test
    public void trademarkChangeTest() throws InterruptedException {

        driver.findElement(By.xpath("//android.widget.TextView[contains(@text,'贝贝服务')]")).click(); //7
        Thread.sleep(1000);

        TouchAction tAction = new TouchAction(driver);
        PointOption firstPointOption = new PointOption();
        firstPointOption.withCoordinates(100, 1500);
        PointOption endPointOption = new PointOption();
        endPointOption.withCoordinates(100, 100);
        tAction.longPress(firstPointOption).moveTo(endPointOption).release().perform();
        Thread.sleep(4000);

        driver.findElement(By.xpath("//android.widget.TextView[contains(@text,'商标变更')]")).click(); //7
        Thread.sleep(1000);
        System.out.println(driver.findElement(By.xpath("//android.widget.TextView[contains(@text,'商标变更')]")).getText());
    }

重点是        tAction.longPress(firstPointOption).moveTo(endPointOption).release().perform();

上滑初始的 y坐标高于 最终的

下滑就是初始的 y坐标 低于最终的

 

截止到目前2020.3.11,真机测试可行,但是虚拟机不可以

    @Test
    public void trademarkChangeTest1() throws InterruptedException {

        driver.findElement(By.xpath("//android.widget.TextView[contains(@text,'贝贝服务')]")).click(); //7
        Thread.sleep(1000);
        new TouchAction(driver).press(PointOption.point(100, 1000)).waitAction().
                moveTo(PointOption.point(100, 400)).release().perform();
        Thread.sleep(4000); //刚启动是必运行这一条
        new TouchAction(driver).press(PointOption.point(100, 1000)).waitAction().
                moveTo(PointOption.point(100, 400)).release().perform();
        Thread.sleep(4000); //第二次运行的才是制定页面的
        driver.findElement(By.xpath("//android.widget.TextView[contains(@text,'商标变更')]")).click(); //7
        Thread.sleep(1000);

    }

虚拟机可以使用的方法,但是不知道为什么刚启动的的时候运行了上滑,不知啊,但是这样功能实现了

 

你可能感兴趣的:(appium,自动化测试,上滑下拉功能)