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

前端 未结 4 883
甜味超标
甜味超标 2021-01-21 12:40

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          


        
4条回答
  •  南方客
    南方客 (楼主)
    2021-01-21 13:09

    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
    

提交回复
热议问题