我想在MAC Chrome上运行我的脚本。我执行了以下步骤
- 从http://chromedriver.storage.googleapis.com/index.html下载最新chrome驱动程序
- 解压缩包,然后将文件复制到/usr/bin
在irb上执行以下步骤
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :chrome
给出以下错误信息
Net::ReadTimeout: Net::ReadTimeout
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/protocol.rb:158:in `rescue in rbuf_fill'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/protocol.rb:152:in `rbuf_fill'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/protocol.rb:134:in `readuntil'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/protocol.rb:144:in `readline'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http/response.rb:39:in `read_status_line'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http/response.rb:28:in `read_new'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:1406:in `block in transport_request'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:1403:in `catch'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:1403:in `transport_request'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:1376:in `request'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:1369:in `block in request'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:852:in `start'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:1367:in `request'
from /Users/vertis/.rvm/gems/ruby-1.9.3-p429/gems/selenium-webdriver-2.39.0/lib/selenium/webdriver/remote/http/default.rb:83:in `response_for'
from /Users/vertis/.rvm/gems/ruby-1.9.3-p429/gems/selenium-webdriver-2.39.0/lib/selenium/webdriver/remote/http/default.rb:39:in `request'
from /Users/vertis/.rvm/gems/ruby-1.9.3-p429/gems/selenium-webdriver-2.39.0/lib/selenium/webdriver/remote/http/common.rb:40:in `call'
from /Users/vertis/.rvm/gems/ruby-1.9.3-p429/gems/selenium-webdriver-2.39.0/lib/selenium/webdriver/remote/bridge.rb:634:in `raw_execute'
from /Users/vertis/.rvm/gems/ruby-1.9.3-p429/gems/selenium-webdriver-2.39.0/lib/selenium/webdriver/remote/bridge.rb:99:in `create_session'
from /Users/vertis/.rvm/gems/ruby-1.9.3-p429/gems/selenium-webdriver-2.39.0/lib/selenium/webdriver/remote/bridge.rb:68:in `initialize'
from /Users/vertis/.rvm/gems/ruby-1.9.3-p429/gems/selenium-webdriver-2.39.0/lib/selenium/webdriver/chrome/bridge.rb:29:in `initialize'
from /Users/vertis/.rvm/gems/ruby-1.9.3-p429/gems/selenium-webdriver-2.39.0/lib/selenium/webdriver/common/driver.rb:37:in `new'
from /Users/vertis/.rvm/gems/ruby-1.9.3-p429/gems/selenium-webdriver-2.39.0/lib/selenium/webdriver/common/driver.rb:37:in `for'
from /Users/vertis/.rvm/gems/ruby-1.9.3-p429/gems/selenium-webdriver-2.39.0/lib/selenium/webdriver.rb:67:in `for'
from (irb):4
下载最新版本的chromedriver并将其保存在usr/local/bin中并运行您的代码,它将工作,因为同样的事情适用于我....如果你想看看哪个版本正在运行,然后去你的chromedriver和右键单击并打开终端。它会显示你的版本,所以请记住,你的版本应该是2.15.XXXXXX
,我很确定它会为你工作!