无法 select 单个对象,因为多个对象具有相同的 ID 和 contentDescription

Could not select single object since multiple objects having the same id and contentDescription

我是 运行 葫芦-android 测试,我的查询响应是

{  
  "id"      =>"recyclerview_businesses",
  "enabled"      =>true,
  "contentDescription"      =>nil,
  "visible"      =>true,
  "tag"      =>nil,
  "description"      =>"android.support.v7.widget.RecyclerView@41fdf4a0",
  "class"      =>"android.support.v7.widget.RecyclerView",
  "rect"      =>      {  
     "center_y"         =>429,
     "center_x"         =>240,
     "height"         =>120,
     "y"         =>369,
     "width"         =>480,
     "x"         =>0
  }
},
{  
  "id"      =>nil,
  "enabled"      =>true,
  "contentDescription"      =>nil,
  "visible"      =>true,
  "tag"      =>nil,
  "description"      =>"android.widget.LinearLayout@41bdd800",
  "class"      =>"android.widget.LinearLayout",
  "rect"      =>      {  
     "center_y"         =>426,
     "center_x"         =>69,
     "height"         =>114,
     "y"         =>369,
     "width"         =>90,
     "x"         =>24
  }
 },
 {  
  "id"      =>"icon",
  "enabled"      =>true,
  "contentDescription"      =>"Businees",
  "visible"      =>true,
  "tag"      =>nil,
  "description"      =>"com.makeramen.roundedimageview.RoundedImageView@41bbfd60",
  "class"      =>"com.makeramen.roundedimageview.RoundedImageView",
  "rect"      =>      {  
     "center_y"         =>426,
     "center_x"         =>69,
     "height"         =>90,
     "y"         =>381,
     "width"         =>90,
     "x"         =>24
  }
 },
 {  
  "id"      =>nil,
  "enabled"      =>true,
  "contentDescription"      =>nil,
  "visible"      =>true,
  "tag"      =>nil,
  "description"      =>"android.widget.LinearLayout@41f38968",
  "class"      =>"android.widget.LinearLayout",
  "rect"      =>      {  
     "center_y"         =>426,
     "center_x"         =>183,
     "height"         =>114,
     "y"         =>369,
     "width"         =>90,
     "x"         =>138
  }
 },
 {  
  "id"      =>"icon",
  "enabled"      =>true,
  "contentDescription"      =>"Businees",
  "visible"      =>true,
  "tag"      =>nil,
  "description"      =>"com.makeramen.roundedimageview.RoundedImageView@41e08b88",
  "class"      =>"com.makeramen.roundedimageview.RoundedImageView",
  "rect"      =>      {  
     "center_y"         =>426,
     "center_x"         =>183,
     "height"         =>90,
     "y"         =>381,
     "width"         =>90,
     "x"         =>138
  }
 },
 {  
  "id"      =>nil,
  "enabled"      =>true,
  "contentDescription"      =>nil,
  "visible"      =>true,
  "tag"      =>nil,
  "description"      =>"android.widget.LinearLayout@41fe17f8",
  "class"      =>"android.widget.LinearLayout",
  "rect"      =>      {  
     "center_y"         =>426,
     "center_x"         =>297,
     "height"         =>114,
     "y"         =>369,
     "width"         =>90,
     "x"         =>252
  }
 },
 {  
  "id"      =>"icon",
  "enabled"      =>true,
  "contentDescription"      =>"Businees",
  "visible"      =>true,
  "tag"      =>nil,
  "description"      =>"com.makeramen.roundedimageview.RoundedImageView@41ee3028",
  "class"      =>"com.makeramen.roundedimageview.RoundedImageView",
  "rect"      =>      {  
     "center_y"         =>426,
     "center_x"         =>297,
     "height"         =>90,
     "y"         =>381,
     "width"         =>90,
     "x"         =>252
  }
 },
 {  
  "id"      =>nil,
  "enabled"      =>true,
  "contentDescription"      =>nil,
  "visible"      =>true,
  "tag"      =>nil,
  "description"      =>"android.widget.RelativeLayout@4205b0f8",
  "class"      =>"android.widget.RelativeLayout",
  "rect"      =>      {  
     "center_y"         =>500,
     "center_x"         =>240,
     "height"         =>25,
     "y"         =>488,
     "width"         =>480,
     "x"         =>0
  }
 },
 {  
  "id"      =>nil,
  "enabled"      =>true,
  "contentDescription"      =>nil,
  "visible"      =>true,
  "tag"      =>nil,
  "description"      =>"android.view.View@41f8d3d8",
  "class"      =>"android.view.View",
  "rect"      =>      {  
     "center_y"         =>500,
     "center_x"         =>101,
     "height"         =>1,
     "y"         =>500,
     "width"         =>202,
     "x"         =>0
  }
 },

这里我想select last object with the id icon and contentDescription Business。最后一个是一个按钮导致另一个弹出 window。这个问题有什么解决办法吗? 任何帮助,将不胜感激。

wait_for_element_exists("* id:'icon' contentDescription:'Business'")
last_index = query("* id:'icon' contentDescription:'Business'").length-1
touch("* id:'icon' contentDescription:'Business' index:#{last_index}")

注意:明确总是更好。如果您知道将有多少个按钮(您很可能会知道),请使用特定索引