Reputation: 953
I am running a calabash-android test and for my query the response is
{
"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
}
},
Here I wanted to select the last object with the id icon and contentDescription Business . The last one is a button leads to another pop up window. Is there any solution for this issue? Any help would be appreciated.
Upvotes: 0
Views: 180
Reputation: 678
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}")
Note: It is always better to be explicit. Use a specific index if you know how many buttons there will be (which you most likely will know)
Upvotes: 1