2015-10-27 61 views
1

任何人都可以請指導我如何觸摸列表視圖的項目;我曾使用iOS的each_cell方法,但同樣不適用於android。葫蘆 - 觸摸列表視圖的列表項爲android

這引發了我一個錯誤 - undefined method each_cell」爲#(NoMethodError)`

感謝

+3

[葫蘆機器人,如點擊一個ListViewη]可能的複製(http://stackoverflow.com/questions/22891225/calabash-android-as-clicking-a-listview) – Lasse

+0

@Selva,請份額幾個代碼和你的列表視圖的截圖。 – Aravin

回答

0

一旦我需要去的日曆準確月拋名單,我的.rb腳本寫信給移動直到我看到元素。我們打開一個githut repo,但沒有提交所有的.rb代碼葫蘆android,可能我不會這樣做,因爲項目處於閒置狀態。

# All elements are inside table which we use to touch alle list elements 
# | x1 | 
# | x2 | 
# | x3 | 
# | x4 | 
# screen shoots go to external folders to make it more clear when you want to see what happend during test 

def moveThroughtList(table) 
    begin 
     # Create Assoc array 
     data = table.raw 
     # Go throw all table elements 
     data.each do |identifiers| 
      identifiers.each do |identifier| 
       #go inside category 
       tap_when_element_exists("* {text CONTAINS[c] '#{identifier}'}") 
       sleep(1) 
       screenshot(options = {:prefix => 'screenshots/', :name => 'category_inside'}) 
       press_back_button 
      end 
     end 
     #It catch all errors and prevent test to stop 
    rescue Calabash::Android::WaitHelpers::WaitError => e 
     puts "Error someting went wrong continue test" 
     #In case of fail do this 
    else 
     screenshot(options = {:prefix => 'screenshots/errors/', :name => 'errors'}) 
     press_back_button 
    end 
end