Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i scroll a UITable view down until i see a cell with label "Value" in Calabash

How do i scroll a UITableView down until i see a cell with label "Value" in Calabash/Cucumber. I've been trying to do it 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 with the above is obviously:

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

Then(/^I swipe down until I see "(.*?)"$/) do |arg1| pending # express the regexp above with the code you wish you had end

like image 259
David Karlsson Avatar asked Dec 18 '25 19:12

David Karlsson


2 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

to the ProjectName/features/step_definitions/my_first_steps.rb ruby file and In your calabash script add

Then I scroll to cell with "AAA" label

its working fine for me.

like image 180
Chathura Palihakkara Avatar answered Dec 20 '25 12:12

Chathura Palihakkara


Every cucumber framework has a set of predefined steps. Of course, these steps don't cover all the possibilites. If you need additional functionality, you have to 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 core functions here

Probably you'll need function

scroll(uiquery, direction)

(where uiquery will be tableView)

If you take this function and element_is_not_hidden you can create a while cycle which will scroll down until you see the "Value".

Maybe 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
like image 39
Sulthan Avatar answered Dec 20 '25 11:12

Sulthan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!