Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/234.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在ActionBar Sherlock中使用葫芦android?_Android_Actionbarsherlock_Calabash - Fatal编程技术网

如何在ActionBar Sherlock中使用葫芦android?

如何在ActionBar Sherlock中使用葫芦android?,android,actionbarsherlock,calabash,Android,Actionbarsherlock,Calabash,我在我的Androi项目中使用葫芦。我想按下动作栏中的一个菜单项Sherlock。此视图是一个图标,其id为R.drawable.info_icon 如果这是我布局的普通视图,我可以使用 step 'I press view with id "info_icon"' 但在《神探夏洛克》中,我犯了一个错误: Step unsuccessful: Could not find view with id: 'info_icon' (RuntimeError) 有人知道我如何在葫芦测试中按下这个视图

我在我的Androi项目中使用葫芦。我想按下动作栏中的一个菜单项Sherlock。此视图是一个图标,其id为R.drawable.info_icon

如果这是我布局的普通视图,我可以使用

step 'I press view with id "info_icon"'
但在《神探夏洛克》中,我犯了一个错误:

Step unsuccessful: Could not find view with id: 'info_icon' (RuntimeError)
有人知道我如何在葫芦测试中按下这个视图吗


谢谢大家!

您所指的id是图像的id,而不是视图的id。 实际上,ActionBar中的任何视图都是不可访问的

相反,您可以尝试根据视图的索引来触摸视图。要查找索引,请查看其中显示了如何使用实时控制台来发现视图。一旦对要触摸的元素进行了良好的查询,只需编写一个自定义步骤,如下所示:

When /^I press the info icon menu item$/ do 
  macro 'I press the menu key'
  wait_for_elements_exist(["IconMenuItemView index:X"])
  touch("IconMenuItemView index:X")
end

X是使用控制台找到的视图的索引。

您所指的id是图像的id,而不是视图的id。 实际上,ActionBar中的任何视图都是不可访问的

相反,您可以尝试根据视图的索引来触摸视图。要查找索引,请查看其中显示了如何使用实时控制台来发现视图。一旦对要触摸的元素进行了良好的查询,只需编写一个自定义步骤,如下所示:

When /^I press the info icon menu item$/ do 
  macro 'I press the menu key'
  wait_for_elements_exist(["IconMenuItemView index:X"])
  touch("IconMenuItemView index:X")
end
X是使用控制台找到的视图的索引