search

Home  >  Q&A  >  body text

monkey - android如何唯一标识一个view

最近用robotium工具做一个有学习能力的自动化monkey工具,但是遇到一个问题,我拿到当前activity的view,选择一个来访问,但是我如何标识我已经访问过这个控件了呢?通过类名,属性,位置以及getid都感觉不太靠谱。大家有什么好的建议么?

高洛峰高洛峰2811 days ago685

reply all(3)I'll reply

  • ringa_lee

    ringa_lee2017-04-17 13:24:53

    1. setTag
    2. setId

    reply
    0
  • 高洛峰

    高洛峰2017-04-17 13:24:53

    Of course view.hashCode()

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-17 13:24:53

    The two methods above are not possible because the tool needs to jump between different activities, and the view will be constantly re-created and destroyed

    reply
    0
  • Cancelreply