Calabash - 触摸android列表视图的列表项

时间:2015-10-27 19:39:39

标签: android ruby cucumber calabash

任何人都可以指导我如何触摸列表视图的项目;我曾经使用过iOS的each_cell方法,但同样适用于android。

它给我一个错误 - undefined method each_cell'代表#(NoMethodError)`

由于

1 个答案:

答案 0 :(得分:0)

有一次我需要把日历中的列表扔到确切的月份,然后我用.rb脚本编写来移动直到我看到元素。我们打开一个githut仓库,但没有提交calabash-android的所有.rb代码,可能我不会这样做因为项目处于空闲状态。

# 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