【问题标题】:Robo script aborts when using SwipeRefreshLayout使用 SwipeRefreshLayout 时 Robo 脚本中止
【发布时间】:2018-11-19 14:16:41
【问题描述】:

我的 Robo 脚本在遇到此结构中的布局时中止:

<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:fitsSystemWindows="true"
tools:context=".ui.AuftraegeActivity">

<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
    android:id="@+id/swipeRefreshLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

        <ListView
            android:id="@+id/projekte_listview"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center_horizontal"
            android:background="@android:color/white"
            android:clipToPadding="false"
            android:divider="#d3d3d3"
            android:dividerHeight="2dp"
            android:paddingStart="10dp"
            android:paddingEnd="10dp"
            android:scrollbarStyle="outsideOverlay"
            android:visibility="gone"
            tools:visibility="visible" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

<include layout="@layout/navdrawer" />

</androidx.drawerlayout.widget.DrawerLayout>

这里我尝试点击ListView的第一个条目。

与服务器成功同步后,ListView 的可见性设置为在 AuftraegeActivity 内可见。同步时会显示一个(UI 阻塞)进度条。

删除SwipeRefreshLayout让Robo脚本成功运行。

这是 Robo 脚本的相关部分:

{
"eventType": "LIST_ITEM_CLICKED",
"timestamp": 1542633892083,
"replacementText": "",
"actionCode": -1,
"delayTime": 0,
"canScrollTo": false,
"elementDescriptors": [
  {
    "className": "android.widget.LinearLayout",
    "recyclerViewChildPosition": -1,
    "adapterViewChildPosition": 0,
    "groupViewChildPosition": -1,
    "resourceId": "de.tarent.ngop.android.debug:id/ll_auftrag_list_item_container",
    "contentDescription": "",
    "text": ""
  },
  {
    "className": "android.widget.ListView",
    "recyclerViewChildPosition": -1,
    "adapterViewChildPosition": -1,
    "groupViewChildPosition": 0,
    "resourceId": "de.tarent.ngop.android.debug:id/projekte_listview",
    "contentDescription": "",
    "text": ""
  },
  {
    "className": "androidx.swiperefreshlayout.widget.SwipeRefreshLayout",
    "recyclerViewChildPosition": -1,
    "adapterViewChildPosition": -1,
    "groupViewChildPosition": 0,
    "resourceId": "de.tarent.ngop.android.debug:id/swipeRefreshLayout",
    "contentDescription": "",
    "text": ""
  }
]
},

【问题讨论】:

    标签: android firebase firebase-test-lab


    【解决方案1】:

    作为解决此问题的一种方法,如果您使用 Espresso 测试记录器(在 Android Studio 中,运行 -> 记录 Espresso 测试)记录相同的操作并查看测试是否存在相同问题,这将有所帮助。如果是(很可能),它将向我们提供有关问题所在的详细错误消息。

    作为目前的解决方法,您可以删除 LIST_ITEM_CLICKED 操作的最后一个元素描述符,即删除大括号中的最后一个块(提到 SwipeRefreshLayout 的那个)以及它前面的逗号。请让我们知道这是否有帮助。谢谢!

    【讨论】:

    • 录制的 Espresso 测试甚至没有进入活动(权限问题)。我试图修复它们,但随后出现了其他问题。我还尝试了您的解决方法,但没有帮助。在 SwipeRefreshLayout 再次失败。
    • 您使用的是哪个 Android Studio 版本?最近的一个应该处理动态权限请求(如果这是您遇到的问题)。如果您可以通过 Espresso 测试重现此问题,这将非常有帮助,因此,如果您在此过程中遇到任何问题,请告诉我。至于 Robo 脚本解决方法,您是否介意将您在上面发布的整个块替换为以下评论中的块并检查它是否有效。谢谢!
    • 请参阅 Robo 脚本块以替换以下答案中的原始脚本块。
    • 我使用的是最新的(v3.2.1)。我无法用 Espresso 重现它,它只是运行失败。我尝试使用新的 Robo 脚本块,但它仍然在同一个地方失败。
    • 感谢您的确认。我很好奇原始问题是否是由于 ListView 可见性的动态更新而发生的。你介意让它永久可见并检查原始 Robo 脚本是否有效吗?另外,如果您对此感到满意,您介意分享原始 Robo 脚本失败的测试矩阵执行链接,以便我可以更深入地了解它吗?谢谢!
    【解决方案2】:
    {
    "eventType": "LIST_ITEM_CLICKED",
    "timestamp": 1542633892083,
    "replacementText": "",
    "actionCode": -1,
    "delayTime": 0,
    "canScrollTo": false,
    "elementDescriptors": [
      {
        "className": "android.widget.LinearLayout",
        "recyclerViewChildPosition": -1,
        "adapterViewChildPosition": 0,
        "groupViewChildPosition": -1,
        "resourceId": "de.tarent.ngop.android.debug:id/ll_auftrag_list_item_container",
        "contentDescription": "",
        "text": ""
      }
    ]
    },
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-20
      • 2021-02-17
      • 1970-01-01
      • 2022-06-10
      • 2022-10-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多