I want to write a Cucumber step definition that scrolls to and selects a specific row in an Android ListView. On iOS I can do the following:
scroll_to_cell(:row => 1, :section => 0)
touch("tableViewCell indexPath:1,0")
How would I do the same thing on Android?
Update: In the calabash-android source, I've found a function called each_item which iterates over every item in a list view. However, I can't quite figure out how it would be valuable yet since it only returns an integer for it's position in the listview as opposed to the item itself. So, I can't do something like...
each_item do |product|
touch(product)
end
The function lives here: https://github.com/calabash/calabash-android/blob/master/ruby-gem/lib/calabash-android/operations.rb#L145
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:
I've verified it in my Android app, it works.