简体   繁体   English

protocol.rb:153:在`read_nonblock'中:到达文件末尾(EOFError)

[英]protocol.rb:153:in `read_nonblock': end of file reached (EOFError)

I'm having a problem with my ruby selenium-driver script that has been working fine up until recently. 我的ruby selenium-driver脚本问题直到最近一直很好。 I can't think of any changes I've done to my environment that may have stopped it working. 我想不出我对我的环境所做的任何改变可能已经阻止了它的工作。

Here's the code: 这是代码:

#!/usr/bin/env ruby

require 'capybara'
require 'selenium-webdriver'
require 'pry'
require 'capybara/dsl'

Capybara.register_driver :chromedriver do |app|
  Capybara::Selenium::Driver.new(app, :browser => :chrome)
end

Capybara.current_driver = :chromedriver

class BulkDoAction
  include Capybara::DSL

  def initialize(file)
    @value_ids = File.readlines file
  end

  def delete(value_id)

    puts "#{Time.now} -> saving value=#{value_id}"
    visit "https://www.url.com/#{value_id}/confirmSave"

    click_button "Save"
    sleep 5.0
  end

  def run
    visit 'https://www.url.com/login'

    fill_in 'Email or Username', with: 'XXX'
    fill_in 'password', with: 'XXX'
    click_button "Login"
    sleep 5.0

    @value_ids.each_with_index do |val_id, idx|
      puts "Doing #{idx + 1} out of #{@value_ids.size}"
      delete val_id.to_i
      sleep 3.0
    end
  end
end

BulkDoAction.new('test.txt').run

I've changed a few of the values, as there is sensitive information. 由于存在敏感信息,我已经更改了一些值。

However, whenever I run this as: 但是,每当我运行它时:

./bulk.rb ./bulk.rb

I get the following exception: 我得到以下异常:

/usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/net/protocol.rb:153:in `read_nonblock': end of file reached (EOFError)
    from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/net/protocol.rb:153:in `rbuf_fill'
    from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/net/protocol.rb:134:in `readuntil'
    from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/net/protocol.rb:144:in `readline'
    from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/net/http/response.rb:39:in `read_status_line'
    from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/net/http/response.rb:28:in `read_new'
    from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/net/http.rb:1414:in `block in transport_request'
    from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/net/http.rb:1411:in `catch'
    from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/net/http.rb:1411:in `transport_request'
    from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/net/http.rb:1384:in `request'
    from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/net/http.rb:1377:in `block in request'
    from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/net/http.rb:853:in `start'
    from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/net/http.rb:1375:in `request'
    from /usr/local/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.0.0/lib/selenium/webdriver/remote/http/default.rb:103:in `response_for'
    from /usr/local/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.0.0/lib/selenium/webdriver/remote/http/default.rb:57:in `request'
    from /usr/local/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.0.0/lib/selenium/webdriver/remote/http/common.rb:59:in `call'
    from /usr/local/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.0.0/lib/selenium/webdriver/remote/bridge.rb:653:in `raw_execute'
    from /usr/local/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.0.0/lib/selenium/webdriver/remote/bridge.rb:124:in `create_session'
    from /usr/local/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.0.0/lib/selenium/webdriver/remote/bridge.rb:88:in `initialize'
    from /usr/local/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.0.0/lib/selenium/webdriver/chrome/bridge.rb:40:in `initialize'
    from /usr/local/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.0.0/lib/selenium/webdriver/common/driver.rb:62:in `new'
    from /usr/local/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.0.0/lib/selenium/webdriver/common/driver.rb:62:in `for'
    from /usr/local/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.0.0/lib/selenium/webdriver.rb:82:in `for'
    from /usr/local/lib/ruby/gems/2.2.0/gems/capybara-2.10.1/lib/capybara/selenium/driver.rb:20:in `browser'
    from /usr/local/lib/ruby/gems/2.2.0/gems/capybara-2.10.1/lib/capybara/selenium/driver.rb:53:in `visit'
    from /usr/local/lib/ruby/gems/2.2.0/gems/capybara-2.10.1/lib/capybara/session.rb:240:in `visit'
    from /usr/local/lib/ruby/gems/2.2.0/gems/capybara-2.10.1/lib/capybara/dsl.rb:52:in `block (2 levels) in <module:DSL>'
    from ./bulk.rb:48:in `run'
    from ./bulk.rb:63:in `<main>'

I get this when I run both the brew installed ruby, and force running the system ruby which is 2.0.0. 当我运行brew安装的ruby时,我得到了这个,并强制运行2.0.0的系统ruby。

I feel as there's something wrong with my gems and being read the script but I can't figure it out. 我觉得我的宝石有问题并且正在阅读剧本,但我无法理解。

Here is my gem list: 这是我的宝石清单:

addressable (2.4.0)
archive-zip (0.7.0)
bigdecimal (1.2.6)
capybara (2.10.1)
childprocess (0.5.9)
chromedriver-helper (1.0.0)
coderay (1.1.1)
ffi (1.9.14)
io-console (0.4.3)
io-like (0.3.0)
json (1.8.1)
method_source (0.8.2)
mime-types (3.1)
mime-types-data (3.2016.0521)
mini_portile2 (2.1.0)
minitest (5.4.3)
multi_json (1.12.1)
nokogiri (1.6.8.1)
power_assert (0.2.2)
pry (0.10.4)
psych (2.0.8)
rack (2.0.1)
rack-test (0.6.3)
rake (10.4.2)
rdoc (4.2.0)
rubyzip (1.2.0)
selenium-webdriver (3.0.0)
slop (3.6.0)
test-unit (3.0.8)
webdriver-firefox (0.0.15)
websocket (1.2.3)
xpath (2.0.0)

So just to clarify, I'm not even getting to the URL when chrome opens up, it is stuck on 'data;' 所以只是为了澄清一下,当Chrome打开时,我甚至没有访问URL,它仍然停留在'数据;' and then it throws the exception in terminal. 然后它在终端中抛出异常。

Nothing has changed with the script, so I think it's something to do with my environment. 脚本没有任何改变,所以我认为这与我的环境有关。

If anyone has any ideas I would be most grateful while I continue trying to figure it out! 如果有人有任何想法,我会非常感激,而我会继续努力解决它!

I have found the same error and I've upgraded chromedriver to version 2.25 (chromedriver_mac64.zip 2016-10-22 06:23:51 4.35MB). 我发现了同样的错误,我已经将chromedriver升级到版本2.25(chromedriver_mac64.zip 2016-10-22 06:23:51 4.35MB)。

Now, it runs perfectly fine. 现在,它运行得非常好。

https://sites.google.com/a/chromium.org/chromedriver/downloads https://sites.google.com/a/chromium.org/chromedriver/downloads

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM