我如何滚动UITable视图,直到我看到一个标签“价值”单元格在葫芦

我如何滚动UITableView,直到我看到一个单元格的标签“价值”在葫芦/黄瓜 。 我一直在尝试使用它:

Then I swipe down until I see "Value" 

并使用:

  Then I scroll down until I see "Value" 

但他们都没有工作。 谢谢!

当我尝试以上时,我得到的消息显然是:

您可以使用以下代码段实现未定义步骤的步骤定义:

然后(/ ^我向下滑动,直到看到“(。*?)”$ /)do | arg1 | 待处理的#用你希望结束的代码expression上面的正则expression式

添加步骤定义

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

到ProjectName / features / step_definitions / my_first_steps.rb ruby​​文件并在你的calabash脚本中添加

 Then I scroll to cell with "AAA" label 

它对我工作很好。

每个黄瓜框架都有一组预定义的步骤。 当然,这些步骤并不包括所有的可能性。 如果你需要额外的function,你必须定义你自己的步骤:

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

我不能帮你准确的实现(什么是“价值”?),但你可以在这里find核心function

可能你会需要function

 scroll(uiquery, direction) 

(其中uiquerytableView

如果你使用这个函数和element_is_not_hidden你可以创build一个while循环,向下滚动,直到你看到“Value”。

也许类似于以下的东西(我不知道葫芦,但我知道弗兰克)

 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 

表具有行和部分,根据您的代码的组织方式使用下面的代码中的行或部分

 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 

以下也应该工作

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

通过以下方式来调用它

 Then I scrolldown until "XY" is visible