With Calabash for Android, how can write a step that scrolls to and touchs a specific listview row?

廉价感情. 提交于 2019-12-04 16:39:34

I can't find a general solution. Android solution will depend on ListView implementation.


The solution that will work for particular ListView is below:

1) First of all, perform query("ListView", {:getItemAtPosition => 1}) and look the property in query result that equals to the text in GUI. For instance, it can be "name".

2) Then you can touch item in specific position with the following step:

Then /^I click the (\d+)(?:st|nd|rd|th) list item$/ do |row|
  scroll_to_row("ListView", row+1)
  touch "* text:\"#{query("ListView", {:getItemAtPosition => row+1})[0]["name"]}\""  
end

I've verified it in my Android app, it works.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!