How to scroll through a ListView until I see a specific row with Calabash-Android

I have the same question as the post below, except that I need it to work on Android and the post below for iOS. I tried both solutions given in this post, but they don't seem to work for Android. All help is appreciated!

How to scroll a UITable view until I see a cell labeled “Value” in Calabash

+6
source share
5 answers

you can add this new step definition and it should do the trick for Android:

Then /^I scroll until I see the "([^\"]*)" text$/ do |text| q = query("TextView text:'#{text}'") while q.empty? scroll_down q = query("TextView text:'#{text}'") end end 

This works for me, and I hope he does the same for you!

+11
source

performAction('scroll_down')

In the statement, the performAction () function is deprecated since calabash 0.5 is not valid with the latest version

My decision will be

 def scroll_until_I_see(id) until element_exists("* marked:'#{id}'") do scroll("ScrollView", :down) end end 
+1
source
  #get total row count count=query("ListView",:getCount).first.to_i var=0 count.times { query("ListView",{:smoothScrollToPosition=>var}) var+=1 puts "#{count} #{var}" #break if id found break if element_exists("* marked:'#{id}'") #fail if all rows are checked fail("#{id} is missing") if var==count } 
+1
source

Here is a method, it will scroll the screen and return an element or an empty array if the element is not found.

 def find_if_exist(text) query_result = query("* marked:'#{text}'") current_screen_state = query('*') prev_screen_state = [] while (query_result.empty? and (current_screen_state != prev_screen_state)) prev_screen_state = current_screen_state perform_action('drag', 50, 50, 60, 40, 20) current_screen_state = query('*') query_result = query("* marked:'#{text}'") end query_result end 
0
source

I have a nested view, so scrolling down with the scroll_down function will return “no scrolling”. Therefore, based on what you all discussed, I find this worker:

 scroll("android.support.v4.widget.NestedScrollView",:down) 

and it scrolls down, but only scrolls once.

0
source

Source: https://habr.com/ru/post/944996/


All Articles