Fixnum与Array的比较失败(ArgumentError)

时间:2014-01-13 10:38:42

标签: ruby selenium watir

当脚本想要增加进度条值时,它会给我:

C:/Ruby193/lib/ruby/gems/1.9.1/gems/ruby-progressbar-1.4.0/lib/ruby-progressbar/components
/progressable.rb:93:in `<=': comparison of Fixnum with Array failed (ArgumentError)

脚本显示为爱。我很想找到解决办法,但没有运气。任何人都可以帮我这个吗?

korpusu_id = []
        container.divs(:class => "resItem") 
        .find_all { |div| div.span(:class => "theText", :text => /TestAuto/).exists? }
    .each do |korpuss|
        id = korpuss.span.parent.parent.attribute_value("id")
        id = id[-38..-1]
        korpusu_id.push(id)
    end


    puts ""
    puts "Tagad notiek nepieciešamo korpusu dzēšana..."
    progress = ProgressBar.create(:title => "Failu dzēšana:", :progress_mark => "|", :format => "%t [%B] %p%%", :total => korpusu_id)
    korpusu_id.each do |korp_id|
        @b.goto("#{@env}/CorpusMetadataEditor.aspx?id=#{korp_id}")
        @b.execute_script("window.confirm = function() {return true}")
        delete_poga = @b.link(:id, "ctl00_ContentPlaceHolder1_lnkDeleteCorpora")
        if delete_poga.exists?
            delete_poga.click
        else
            puts "Korpuss\n#{@env}/CorpusMetadataEditor.aspx?id=#{korp_id}\nlietotājam #{lietotajs} nav pieejams rediģēšanai.\nTurpinu ar nākošo korpusu!\n---------------------------------------------"
            next
        end
        container.div(:class => "resItem").wait_until_present
        progress.increment
    end

1 个答案:

答案 0 :(得分:0)

我找到了问题的最终解决方案。我改变了:

progress = ProgressBar.create(:title => "Failu dzēšana:", :progress_mark => "|", :format => "%t [%B] %p%%", :total => korpusu_id.length) 

这对我有用。

对不起垃圾邮件......