【问题标题】:Inserting delays into robo test script after creating it in the robo script recorder在 robo 脚本记录器中创建后将延迟插入到 robo 测试脚本中
【发布时间】:2023-03-20 07:05:01
【问题描述】:

自动创建的 rob 脚本不会在我知道我的应用程序在执行脚本化设置操作时需要的地方插入延迟。我如何使用我认为可能的这两个选项中的任何一个,或者是否有批准的方法?我找不到任何脚本命令指南,所以我瞎了。

  1. 获取现有“DELAYED_MESSAGE_POSTED”的副本并将其移动到我想要增加延迟的位置。

  2. 编辑我想要在之前/之后额外延迟的事件的“delayTime”。

我已经尝试过 #1 和 #2,但似乎在我编辑后脚本不会运行,所以要么这些不是解决这个问题的方法,要么我搞砸了。任何指导将不胜感激。

这是脚本中的一个 sn-p,它具有两种方法。我在此脚本中的 cmets(仅用于此发布,而不是在我运行的脚本中)以“

[
...
{
    "eventType": "DELAYED_MESSAGE_POSTED",
    "timestamp": 1570820588045,
    "actionCode": -1,
    "delayTime": 7000,
    "canScrollTo": false,
    "elementDescriptors": []
  },
  {
    "eventType": "VIEW_CLICKED",
    "timestamp": 1570820599551,
    "replacementText": "",
    "actionCode": -1,
    "delayTime": 0,
    "canScrollTo": false,
    "elementDescriptors": [
      {
        "className": "androidx.appcompat.widget.AppCompatImageButton",
        "recyclerViewChildPosition": -1,
        "adapterViewChildPosition": -1,
        "groupViewChildPosition": 2,
        "resourceId": "com.jingleware.sosalert:id/ForwardArrow6",
        "contentDescription": "",
        "text": ""
      },
      {
        "className": "android.widget.RelativeLayout",
        "recyclerViewChildPosition": -1,
        "adapterViewChildPosition": -1,
        "groupViewChildPosition": 0,
        "resourceId": "com.jingleware.sosalert:id/thanks",
        "contentDescription": "",
        "text": ""
      },
      {
        "className": "android.widget.RelativeLayout",
        "recyclerViewChildPosition": -1,
        "adapterViewChildPosition": -1,
        "groupViewChildPosition": 0,
        "resourceId": "com.jingleware.sosalert:id/pager",
        "contentDescription": "",
        "text": ""
      }
    ]
  },
  {  <<<<- added delay  using the first method>
    "eventType": "DELAYED_MESSAGE_POSTED",
    "timestamp": 1570820605000,               <<<<- Here's where I stuck in a value, not knowing what the effect would be 
    "actionCode": -1,
    "delayTime": 1000,
    "canScrollTo": false,
    "elementDescriptors": []
  },
  {
    "eventType": "VIEW_CLICKED",
    "timestamp": 1570820606462,
    "replacementText": "",
    "actionCode": -1,
    "delayTime": 0,            <<<<- I tried to set this to 1000, without the discrete delay that's shown above 
    "canScrollTo": true,
    "elementDescriptors": [
      {
        "className": "androidx.appcompat.widget.AppCompatButton",
        "recyclerViewChildPosition": -1,
        "adapterViewChildPosition": -1,
        "groupViewChildPosition": 1,
        "resourceId": "com.jingleware.sosalert:id/NameField",
        "contentDescription": "",
        "text": ""
      },
      {
        "className": "android.widget.RelativeLayout",
        "recyclerViewChildPosition": -1,
        "adapterViewChildPosition": -1,
        "groupViewChildPosition": 0,
        "resourceId": "com.jingleware.sosalert:id/userinfoinfo",
        "contentDescription": "",
        "text": ""
      },
      {
        "className": "android.widget.ScrollView",
        "recyclerViewChildPosition": -1,
        "adapterViewChildPosition": -1,
        "groupViewChildPosition": 0,
        "resourceId": "com.jingleware.sosalert:id/userinfoscroller",
        "contentDescription": "",
        "text": ""
      },
      {
        "className": "android.widget.RelativeLayout",
        "recyclerViewChildPosition": -1,
        "adapterViewChildPosition": -1,
        "groupViewChildPosition": 1,
        "resourceId": "com.jingleware.sosalert:id/userinfo",
        "contentDescription": "",
        "text": ""
      }
    ]
  },
...
]

【问题讨论】:

    标签: android firebase android-testing firebase-test-lab


    【解决方案1】:

    选项#1 是要走的路。您分配给“时间戳”的值可以从另一个事件中复制。在注入“DELAYED_MESSAGE_POSTED”的副本时,请确保生成的脚本是格式正确的 JSON(即,需要逗号,没有不需要的逗号,括号匹配等)。查看您的示例脚本,我认为这是一个有效的更改,并且延迟应该有效(假设 1 秒的延迟足以让您的应用稳定)。

    您提到在选项 #1 更改后,您的脚本将无法运行。这是否意味着整个脚本没有执行,或者它运行到某个操作然后失败?原始版本和修改版本之间的脚本执行有何不同(例如,在哪个操作处失败)?谢谢!

    【讨论】:

    • 谢谢,斯坦尼斯拉夫!我错过了逗号;现在工作正常。你能推荐一个可以验证 JSON 文件的工具吗?
    • 还有机器人脚本的命令参考吗?很难弄清楚我需要在(android studio)自动生成的脚本中修改什么才能正确找到我的 ViewPager 孩子。
    • 我个人从来没有使用过验证JSON文件的工具,但我认为确实可能有这样的工具,你可以搜索一下。
    • 关于 Robo 脚本的命令参考,目前还没有。最初,Roboscripts 被设计为黑盒测试,只有在极少数特殊情况下才需要更改用户。由于人们对编辑 Roboscripts 感兴趣,我们可能会重新审视这种方法,但与此同时,唯一的选择是从录制的 Roboscripts 中学习并在公共论坛上提问。
    猜你喜欢
    • 2021-02-17
    • 1970-01-01
    • 1970-01-01
    • 2022-06-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-27
    相关资源
    最近更新 更多