无法在appium android中滚动到回收器视图的底部

o3imoua4  于 2021-07-09  发布在  Java
关注(0)|答案(1)|浏览(480)

我使用的是appium 1.18.0、java客户端7.3.0
此版本不再支持尝试在recyclerview的底部滚动,但不支持success swipe()方法,触摸操作可以完成此任务,但其过程太慢,需要指定滚动次数。如果添加新数据,则需要增加滚动次数此处是我的xml:

<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<hierarchy index="0" class="hierarchy" rotation="0" width="720" height="1456">
  <android.widget.FrameLayout index="0" package="opms.com" class="android.widget.FrameLayout" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,0][720,1456]" displayed="true">
    <android.widget.LinearLayout index="0" package="opms.com" class="android.widget.LinearLayout" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,0][720,1456]" displayed="true">
      <android.widget.FrameLayout index="0" package="opms.com" class="android.widget.FrameLayout" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,0][720,1456]" displayed="true">
        <android.widget.LinearLayout index="0" package="opms.com" class="android.widget.LinearLayout" text="" resource-id="opms.com:id/action_bar_root" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,0][720,1456]" displayed="true">
          <android.widget.FrameLayout index="0" package="opms.com" class="android.widget.FrameLayout" text="" resource-id="android:id/content" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,0][720,1456]" displayed="true">
            <androidx.drawerlayout.widget.DrawerLayout index="0" package="opms.com" class="androidx.drawerlayout.widget.DrawerLayout" text="" resource-id="opms.com:id/drawer_layout" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,0][720,1456]" displayed="true">
              <android.view.ViewGroup index="0" package="opms.com" class="android.view.ViewGroup" text="" resource-id="opms.com:id/app_bar" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,56][720,1456]" displayed="true">
                <android.widget.LinearLayout index="0" package="opms.com" class="android.widget.LinearLayout" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,56][720,168]" displayed="true">
                  <android.view.ViewGroup index="0" package="opms.com" class="android.view.ViewGroup" text="" resource-id="opms.com:id/toolbar" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,56][720,168]" displayed="true">
                    <android.widget.ImageButton index="0" package="opms.com" class="android.widget.ImageButton" text="" content-desc="Navigate up" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,56][112,168]" displayed="true" />
                    <android.widget.TextView index="1" package="opms.com" class="android.widget.TextView" text="Appointmnet" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[144,84][385,139]" displayed="true" />
                    <androidx.appcompat.widget.LinearLayoutCompat index="2" package="opms.com" class="androidx.appcompat.widget.LinearLayoutCompat" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[557,56][720,168]" displayed="true">
                      <android.widget.TextView index="0" package="opms.com" class="android.widget.TextView" text="LOGOUT" resource-id="opms.com:id/action_logout" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[557,64][720,160]" displayed="true" />
                    </androidx.appcompat.widget.LinearLayoutCompat>
                  </android.view.ViewGroup>
                </android.widget.LinearLayout>
                <android.view.ViewGroup index="1" package="opms.com" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,168][720,1456]" displayed="true">
                  <android.widget.FrameLayout index="0" package="opms.com" class="android.widget.FrameLayout" text="" resource-id="opms.com:id/nav_host_fragment" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,168][720,1456]" displayed="true">
                    <android.view.ViewGroup index="0" package="opms.com" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,168][720,1456]" displayed="true">
                      <android.widget.TextView index="0" package="opms.com" class="android.widget.TextView" text="Pull up for refresh" resource-id="opms.com:id/tv_swipe_up" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[249,184][471,223]" displayed="true" />
                      <android.view.ViewGroup index="1" package="opms.com" class="android.view.ViewGroup" text="" resource-id="opms.com:id/swipe_view" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[0,239][720,1456]" displayed="true">
                        <androidx.recyclerview.widget.RecyclerView index="0" package="opms.com" class="androidx.recyclerview.widget.RecyclerView" text="" resource-id="opms.com:id/appointment_recycler" checkable="false" checked="false" clickable="false" enabled="true" focusable="true" focused="false" long-clickable="false" password="false" scrollable="true" selected="false" bounds="[0,239][720,1456]" displayed="true">
                          <androidx.cardview.widget.CardView index="0" package="opms.com" class="androidx.cardview.widget.CardView" text="" resource-id="opms.com:id/cv_centre" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[16,255][704,478]" displayed="true">
                            <android.view.ViewGroup index="0" package="opms.com" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[16,255][704,478]" displayed="true">
                              <android.widget.TextView index="0" package="opms.com" class="android.widget.TextView" text="Mangalam Clinic" resource-id="opms.com:id/tv_centre_name" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,279][469,334]" displayed="true" />
                              <android.widget.TextView index="1" package="opms.com" class="android.widget.TextView" text="No. 9033060056" resource-id="opms.com:id/tv_centre_no" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[469,287][680,326]" displayed="true" />
                              <android.widget.TextView index="2" package="opms.com" class="android.widget.TextView" text="Visit purpose : teething" resource-id="opms.com:id/tv_visit_purpose" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,366][680,410]" displayed="true" />
                              <android.widget.TextView index="3" package="opms.com" class="android.widget.TextView" text="Visit time : 22-08-2020 02:00 pm" resource-id="opms.com:id/tv_appointment_date" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,418][680,462]" displayed="true" />
                            </android.view.ViewGroup>
                          </androidx.cardview.widget.CardView>
                          <androidx.cardview.widget.CardView index="1" package="opms.com" class="androidx.cardview.widget.CardView" text="" resource-id="opms.com:id/cv_centre" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[16,510][704,733]" displayed="true">
                            <android.view.ViewGroup index="0" package="opms.com" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[16,510][704,733]" displayed="true">
                              <android.widget.TextView index="0" package="opms.com" class="android.widget.TextView" text="Mrj" resource-id="opms.com:id/tv_centre_name" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,534][469,589]" displayed="true" />
                              <android.widget.TextView index="1" package="opms.com" class="android.widget.TextView" text="No. 7046400031" resource-id="opms.com:id/tv_centre_no" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[469,542][680,581]" displayed="true" />
                              <android.widget.TextView index="2" package="opms.com" class="android.widget.TextView" text="Visit purpose : tr" resource-id="opms.com:id/tv_visit_purpose" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,621][680,665]" displayed="true" />
                              <android.widget.TextView index="3" package="opms.com" class="android.widget.TextView" text="Visit time : 21-08-2020 12:00 am" resource-id="opms.com:id/tv_appointment_date" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,673][680,717]" displayed="true" />
                            </android.view.ViewGroup>
                          </androidx.cardview.widget.CardView>
                          <androidx.cardview.widget.CardView index="2" package="opms.com" class="androidx.cardview.widget.CardView" text="" resource-id="opms.com:id/cv_centre" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[16,765][704,988]" displayed="true">
                            <android.view.ViewGroup index="0" package="opms.com" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[16,765][704,988]" displayed="true">
                              <android.widget.TextView index="0" package="opms.com" class="android.widget.TextView" text="test center" resource-id="opms.com:id/tv_centre_name" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,789][469,844]" displayed="true" />
                              <android.widget.TextView index="1" package="opms.com" class="android.widget.TextView" text="No. 1234567890" resource-id="opms.com:id/tv_centre_no" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[469,797][680,836]" displayed="true" />
                              <android.widget.TextView index="2" package="opms.com" class="android.widget.TextView" text="Visit purpose : teeth prob edit" resource-id="opms.com:id/tv_visit_purpose" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,876][680,920]" displayed="true" />
                              <android.widget.TextView index="3" package="opms.com" class="android.widget.TextView" text="Visit time : 11-08-2020 05:09 pm" resource-id="opms.com:id/tv_appointment_date" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,928][680,972]" displayed="true" />
                            </android.view.ViewGroup>
                          </androidx.cardview.widget.CardView>
                          <androidx.cardview.widget.CardView index="3" package="opms.com" class="androidx.cardview.widget.CardView" text="" resource-id="opms.com:id/cv_centre" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[16,1020][704,1243]" displayed="true">
                            <android.view.ViewGroup index="0" package="opms.com" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[16,1020][704,1243]" displayed="true">
                              <android.widget.TextView index="0" package="opms.com" class="android.widget.TextView" text="Mrj" resource-id="opms.com:id/tv_centre_name" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,1044][469,1099]" displayed="true" />
                              <android.widget.TextView index="1" package="opms.com" class="android.widget.TextView" text="No. 7046400031" resource-id="opms.com:id/tv_centre_no" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[469,1052][680,1091]" displayed="true" />
                              <android.widget.TextView index="2" package="opms.com" class="android.widget.TextView" text="Visit purpose : ortho." resource-id="opms.com:id/tv_visit_purpose" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,1131][680,1175]" displayed="true" />
                              <android.widget.TextView index="3" package="opms.com" class="android.widget.TextView" text="Visit time : 21-07-2020 09:00 am" resource-id="opms.com:id/tv_appointment_date" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,1183][680,1227]" displayed="true" />
                            </android.view.ViewGroup>
                          </androidx.cardview.widget.CardView>
                          <androidx.cardview.widget.CardView index="4" package="opms.com" class="androidx.cardview.widget.CardView" text="" resource-id="opms.com:id/cv_centre" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[16,1275][704,1456]" displayed="true">
                            <android.view.ViewGroup index="0" package="opms.com" class="android.view.ViewGroup" text="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[16,1275][704,1456]" displayed="true">
                              <android.widget.TextView index="0" package="opms.com" class="android.widget.TextView" text="Sanjeevani Dental Clinic" resource-id="opms.com:id/tv_centre_name" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,1299][469,1402]" displayed="true" />
                              <android.widget.TextView index="1" package="opms.com" class="android.widget.TextView" text="No. 8160619241" resource-id="opms.com:id/tv_centre_no" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[469,1331][680,1370]" displayed="true" />
                              <android.widget.TextView index="2" package="opms.com" class="android.widget.TextView" text="Visit purpose : Teeth Treat" resource-id="opms.com:id/tv_visit_purpose" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,1434][680,1456]" displayed="true" />
                              <android.widget.TextView index="3" package="opms.com" class="android.widget.TextView" text="Visit time : 28-01-2020 05:30 am" resource-id="opms.com:id/tv_appointment_date" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[40,1486][680,1512]" displayed="true" />
                            </android.view.ViewGroup>
                          </androidx.cardview.widget.CardView>
                        </androidx.recyclerview.widget.RecyclerView>
                      </android.view.ViewGroup>
                      <android.widget.Button index="2" package="opms.com" class="android.widget.Button" text="Add Appointment" resource-id="opms.com:id/btn_add_appointment" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[261,1368][672,1456]" displayed="true" />
                    </android.view.ViewGroup>
                  </android.widget.FrameLayout>
                </android.view.ViewGroup>
              </android.view.ViewGroup>
            </androidx.drawerlayout.widget.DrawerLayout>
          </android.widget.FrameLayout>
        </android.widget.LinearLayout>
      </android.widget.FrameLayout>
    </android.widget.LinearLayout>
  </android.widget.FrameLayout>
</hierarchy>

如果有人有主意,请帮忙
谢谢

mrwjdhj3

mrwjdhj31#

如果您知道要滚动到的文本,可以使用下面的代码。

((FindsByAndroidUIAutoamtor<?>)(driver).find_element_by_android_uiautomator('new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textContains("**Expected text**").instance(0))');

如果您没有任何特定的文本可以滚动到您使用任何随机文本代替预期的文本,并使用try块中的代码,这将滚动到底部。

相关问题