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

How to scroll a UITableView until I see a cell labeled “Value” in Calabash / Cucumber . I tried to do this using:

Then I swipe down until I see "Value" 

and using:

  Then I scroll down until I see "Value" 

but none of them seem to work. Thanks!

The message I get when I try to do this is obviously:

You can implement step definitions for undefined steps with these snippets:

Then (/ ^ I scroll down until I see "(. *?)" $ /) Do | arg1 | waiting # express regexp above with the code you would like to have.

+2
source share
4 answers

add step definitions

 Then /^I scroll to cell with "([^\"]*)" label$/ do |name| wait_poll(:until_exists => "label text:'#{name}'", :timeout => 20) do scroll("tableView", :down) end end 

in the file ProjectName / features / step_definitions / my_first_steps.rb ruby ​​and in the calabate script add

 Then I scroll to cell with "AAA" label 

its working fine for me.

+11
source

Each cucumber structure has a set of predefined steps. Of course, these steps do not cover all the possibilities. If you need additional functionality, you must define your own steps:

 When /^I scroll (up|down) until I see "([^\"]*)"$/ do |direction, something_to_see| #implement the step here end 

I can’t help you with the exact implementation (what is “Value”?), But you can find the main functions here

You probably need a function

 scroll(uiquery, direction) 

(where uiquery will be a tableView )

If you take this function and element_is_not_hidden , you can create a while that will scroll down until you see the “Value”.

Perhaps something similar to the following (I don't know Calabash, but I know Frank a little)

 When /^I scroll (up|down) until I see "([^\"]*)"$/ do |direction, something_to_see| max_scroll_tries = 10 [0..max_scroll_tries].each do break if element_is_not_hidden("view marked:'#{something_to_see}'") scroll("tableView", direction) end check_element_exists_and_is_visible("view marked:'#{something_to_see}'") end 
+2
source

the table contains lines and sections based on how your code is organized using lines or sections in the code below

 def scroll_side_panel(text) section=0 scroll_to_cell(:row => 0, :section => 0) # scroll to top of view sleep 1 # wait for a second #Scroll to each element and compare text, if there is a match break each_cell(:animate => false, :post_scroll => 0.2) do |row, sec| puts "#{query("tableViewCell indexPath:#{row},#{sec} label", :text)} #{text}" if query("tableViewCell indexPath:#{row},#{sec} label", :text).first==text break end section=section+1 end puts "table view text found at element number:#{section}" end 
+1
source

should also work

 Then(/^I scrolldown until "(.*?)" is visible$/) do |arg1| until query("lable text:'#{arg1}'").length > 0 scroll("tableView", :down) end end 

Call it by following

 Then I scrolldown until "XY" is visible 
+1
source

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


All Articles