java实现滑动列表找到目标并且选择

有时候遇到列表,目标元素还不在第一页,需要上滑或者下滑,加载显示到第二页,找到元素后,并且进入成功

滑动找到元素后并且点击

    //列表格式页面,想打开的一行没有在第一页,需要上下滑动才可以使用以下方法
    public static void swipeToElement() throws InterruptedException {
        // 1、点击群组
        androidDriver.findElementById("com.cmcc.p.poc:id/layout_group_list").click();
        Thread.sleep(3000);
        //2.找到元素并且进入
        androidDriver
                .findElementByAndroidUIAutomator(
                        "new UiScrollable(new UiSelector().scrollable(true).instance(0))."
                        + "scrollIntoView(new UiSelector().textMatches("月色江声").instance(0))").click();
        Thread.sleep(5000);
    }

原文地址:https://www.cnblogs.com/tiansc1/p/15016014.html