51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 2023|回复: 4
打印 上一主题 下一主题

执行 driver.findElements (By.name ().isEmpty () 方法-偶尔会出现页面存在该元素...

[复制链接]
  • TA的每日心情
    无聊
    昨天 09:08
  • 签到天数: 531 天

    连续签到: 1 天

    [LV.9]测试副司令

    跳转到指定楼层
    1#
    发表于 2019-8-22 11:08:41 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
    1测试积点
    执行 driver.findElements (By.name ().isEmpty () 方法-偶尔会出现页面存在该元素却无法获取的现象

    appium Server版本: 1.3.4.1

    代码如下:

    1. String elementsNeedToFind = "autotest-IP-DVR";
    2. driver.findElements(By.name(elementsNeedToFind)).isEmpty()
    复制代码

    日志如下:

    1. > info: --> POST /wd/hub/session/a0b028fb-1375-44cb-a988-d32adc5e149b/elements {"using":"name","value":"autotest-IP-DVR"}
    2. > info: [debug] Waiting up to 2000ms for condition
    3. > info: [debug] Pushing command to appium work queue: ["find",{"strategy":"name","selector":"autotest-IP-DVR","context":"","multiple":true}]
    4. > info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"name","selector":"autotest-IP-DVR","context":"","multiple":true}}
    5. > info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
    6. > info: [debug] [BOOTSTRAP] [debug] Got command action: find
    7. > info: [debug] [BOOTSTRAP] [debug] Finding autotest-IP-DVR using NAME with the contextId:  multiple: true
    8. > info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[DESCRIPTION=autotest-IP-DVR]
    9. > info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[DESCRIPTION=autotest-IP-DVR]
    10. > info: [debug] [BOOTSTRAP] [debug] Element[] is null: (0)
    11. > info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[DESCRIPTION=autotest-IP-DVR, INSTANCE=0]
    12. > info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[TEXT=autotest-IP-DVR]
    13. > info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[TEXT=autotest-IP-DVR]
    14. > info: [debug] [BOOTSTRAP] [debug] Element[] is null: (0)
    15. > info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[TEXT=autotest-IP-DVR, INSTANCE=0]
    16. > info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":[],"status":0}
    17. > info: [debug] Waited for 114ms so far
    18. > info: [debug] Pushing command to appium work queue: ["find",{"strategy":"name","selector":"autotest-IP-DVR","context":"","multiple":true}]
    19. > info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"name","selector":"autotest-IP-DVR","context":"","multiple":true}}
    20. > info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
    21. > info: [debug] [BOOTSTRAP] [debug] Got command action: find
    22. > info: [debug] [BOOTSTRAP] [debug] Finding autotest-IP-DVR using NAME with the contextId:  multiple: true
    23. > info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[DESCRIPTION=autotest-IP-DVR]
    24. > info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[DESCRIPTION=autotest-IP-DVR]
    25. > info: [debug] [BOOTSTRAP] [debug] Element[] is null: (0)
    26. > info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[DESCRIPTION=autotest-IP-DVR, INSTANCE=0]
    27. > info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[TEXT=autotest-IP-DVR]
    28. > info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[TEXT=autotest-IP-DVR]
    29. > info: [debug] [BOOTSTRAP] [debug] Element[] is null: (0)
    30. > info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[TEXT=autotest-IP-DVR, INSTANCE=0]
    31. > info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":[],"status":0}
    32. > info: [debug] Waited for 698ms so far
    33. > info: [debug] Pushing command to appium work queue: ["find",{"strategy":"name","selector":"autotest-IP-DVR","context":"","multiple":true}]
    34. > info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"name","selector":"autotest-IP-DVR","context":"","multiple":true}}
    35. > info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
    36. > info: [debug] [BOOTSTRAP] [debug] Got command action: find
    37. > info: [debug] [BOOTSTRAP] [debug] Finding autotest-IP-DVR using NAME with the contextId:  multiple: true
    38. > info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[DESCRIPTION=autotest-IP-DVR]
    39. > info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[DESCRIPTION=autotest-IP-DVR]
    40. > info: [debug] [BOOTSTRAP] [debug] Element[] is null: (0)
    41. > info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[DESCRIPTION=autotest-IP-DVR, INSTANCE=0]
    42. > info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[TEXT=autotest-IP-DVR]
    43. > info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[TEXT=autotest-IP-DVR]
    44. > info: [debug] [BOOTSTRAP] [debug] Element[] is null: (0)
    45. > info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[TEXT=autotest-IP-DVR, INSTANCE=0]
    46. > info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":[],"status":0}
    47. > info: [debug] Waited for 1465ms so far
    48. > info: [debug] Pushing command to appium work queue: ["find",{"strategy":"name","selector":"autotest-IP-DVR","context":"","multiple":true}]
    49. > info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"name","selector":"autotest-IP-DVR","context":"","multiple":true}}
    50. > info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
    51. > info: [debug] [BOOTSTRAP] [debug] Got command action: find
    52. > info: [debug] [BOOTSTRAP] [debug] Finding autotest-IP-DVR using NAME with the contextId:  multiple: true
    53. > info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[DESCRIPTION=autotest-IP-DVR]
    54. > info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[DESCRIPTION=autotest-IP-DVR]
    55. > info: [debug] [BOOTSTRAP] [debug] Element[] is null: (0)
    56. > info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[DESCRIPTION=autotest-IP-DVR, INSTANCE=0]
    57. > info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[TEXT=autotest-IP-DVR]
    58. > info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[TEXT=autotest-IP-DVR]
    59. > info: [debug] [BOOTSTRAP] [debug] Element[] is null: (0)
    60. > info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[TEXT=autotest-IP-DVR, INSTANCE=0]
    61. > info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":[],"status":0}
    62. > info: [debug] Condition unmet after 2287ms. Timing out.
    复制代码

    截图如下:

    现象:执行的时候偶尔会出现无法定位到这个元素,结果isEmpty()为true,但页面上这个元素是存在的。
    求大神指点!!



    附件: 您需要 登录 才可以下载或查看,没有帐号?(注-册)加入51Testing
    分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
    收藏收藏
    回复

    使用道具 举报

  • TA的每日心情
    奋斗
    昨天 10:15
  • 签到天数: 1523 天

    连续签到: 2 天

    [LV.Master]测试大本营

    2#
    发表于 2019-8-23 10:38:29 | 只看该作者
    加个等待时间
    回复

    使用道具 举报

  • TA的每日心情

    2020-2-2 12:43
  • 签到天数: 630 天

    连续签到: 1 天

    [LV.9]测试副司令

    3#
    发表于 2019-8-23 11:43:52 | 只看该作者
    不知
    回复

    使用道具 举报

  • TA的每日心情
    奋斗
    昨天 16:45
  • 签到天数: 998 天

    连续签到: 2 天

    [LV.10]测试总司令

    4#
    发表于 2019-8-23 11:45:15 | 只看该作者
    可能是上一个页面还没有加载完,直接获取页面上的东西会获取不到,加一个2s的等待时间,应该可以解决
    回复

    使用道具 举报

  • TA的每日心情
    奋斗
    昨天 07:30
  • 签到天数: 2820 天

    连续签到: 2 天

    [LV.Master]测试大本营

    5#
    发表于 2019-8-23 12:25:31 | 只看该作者
    等待是否出现
    回复

    使用道具 举报

    本版积分规则

    关闭

    站长推荐上一条 /1 下一条

    小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

    GMT+8, 2024-11-27 03:57 , Processed in 0.067789 second(s), 22 queries .

    Powered by Discuz! X3.2

    © 2001-2024 Comsenz Inc.

    快速回复 返回顶部 返回列表