>我正在运行一个葫芦-安卓测试,对于我的查询,响应是
{
"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
}
},
这里我想选择最后一个带有id图标和内容描述业务的对象。最后一个是指向另一个弹出窗口的按钮。这个问题有什么解决方案吗?任何帮助将不胜感激。
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}")
注意:最好是明确。如果您知道将有多少个按钮(您很可能会知道),请使用特定索引