Ruby on Rails undefined方法`[]'为真:TrueClass Capybara&吵闹鬼

时间:2014-04-02 10:05:53

标签: ruby-on-rails ruby capybara poltergeist

在运行我的工作人员时,我一直收到undefined method '[]' for true:TrueClass的间歇性错误。一半的时间它会工作,然后另一个它只是失败了这个错误。如果我尝试同时运行多个工作人员似乎只会发生这种情况,但他们并没有执行相同的任务......

    2014-04-02T08:00:02Z 48940 TID-oukh38lzc WARN: {"retry"=>true, "queue"=>"default", "class"=>"TrackerWorker", "args"=>[1151], "jid"=>"9cb5d0bd4519afda81e999ec", "enqueued_at"=>1396425476.576768, "error_message"=>"undefined method `[]' for true:TrueClass", "error_class"=>"NoMethodError", "failed_at"=>2014-04-02 08:00:02 UTC, "retry_count"=>0}
    2014-04-02T08:00:02Z 48940 TID-oukh38lzc WARN: undefined method `[]' for true:TrueClass
    2014-04-02T08:00:02Z 48940 TID-oukh38lzc WARN: /Users/max/.rvm/gems/ruby-2.0.0-p353@rocket/gems/poltergeist-1.5.0/lib/capybara/poltergeist/browser.rb:54:in `find'
    /Users/max/.rvm/gems/ruby-2.0.0-p353@rocket/gems/poltergeist-1.5.0/lib/capybara/poltergeist/driver.rb:114:in `find'
    /Users/max/.rvm/gems/ruby-2.0.0-p353@rocket/gems/poltergeist-1.5.0/lib/capybara/poltergeist/driver.rb:118:in `find_xpath'
    /Users/max/.rvm/gems/ruby-2.0.0-p353@rocket/gems/capybara-2.2.0/lib/capybara/node/finders.rb:154:in `block in resolve_query'
    /Users/max/.rvm/gems/ruby-2.0.0-p353@rocket/gems/capybara-2.2.0/lib/capybara/node/base.rb:77:in `synchronize'
    /Users/max/.rvm/gems/ruby-2.0.0-p353@rocket/gems/capybara-2.2.0/lib/capybara/node/finders.rb:150:in `resolve_query'
    /Users/max/.rvm/gems/ruby-2.0.0-p353@rocket/gems/capybara-2.2.0/lib/capybara/node/finders.rb:32:in `block in find'
    /Users/max/.rvm/gems/ruby-2.0.0-p353@rocket/gems/capybara-2.2.0/lib/capybara/node/base.rb:81:in `synchronize'
    /Users/max/.rvm/gems/ruby-2.0.0-p353@rocket/gems/capybara-2.2.0/lib/capybara/node/finders.rb:30:in `find'
    /Users/max/.rvm/gems/ruby-2.0.0-p353@rocket/gems/capybara-2.2.0/lib/capybara/node/actions.rb:53:in `fill_in'
    /Users/max/.rvm/gems/ruby-2.0.0-p353@rocket/gems/capybara-2.2.0/lib/capybara/session.rb:396:in `block (2 levels) in <class:Session>'
    /Users/max/.rvm/gems/ruby-2.0.0-p353@rocket/gems/capybara-2.2.0/lib/capybara/dsl.rb:51:in `block (2 levels) in <module:DSL>'

我的工作人员的一个例子如下,并不是很复杂。

    options = {
      :js_errors => false,
    }
    Capybara.register_driver :poltergeist do |app|
      Capybara::Poltergeist::Driver.new(app, options)
    end
    Capybara.default_driver = :poltergeist
    Capybara.javascript_driver = :poltergeist
    Capybara.default_wait_time = 20
    Capybara.ignore_hidden_elements = true

    begin
      visit('/')
      sleep 2
      save_screenshot("/Users/max/Sites/rocket/screens/0.jpg",  full: true)
      sleep 2
      fill_in "search", :with => 'testing' 
      sleep 2
      save_screenshot("/Users/max/Sites/rocket/screens/1.jpg",  full: true)
      sleep 2
      click_button "Search"
      sleep 2
      save_screenshot("/Users/max/Sites/rocket/2.jpg",  full: true)
    end

它将采用第一个屏幕截图然后失败。

1 个答案:

答案 0 :(得分:0)

此处已报告https://github.com/teampoltergeist/poltergeist/issues/482并且仍处于打开状态。