我正在尝试在 Amazon EC2 上设置 Jenkins 构建服务器。我计划在无头模式下运行我的黄瓜测试套件。我成功地在 IRB 中无头运行
require 'watir-webdriver'
require 'headless'
headless = Headless.new
headless.start
b = Watir::Browser.new(:chrome)
b.goto("www.google.com")
b.title
b.close
headless.destroy
但是如果我将以下内容添加到我的 env.rb
if ENV['HEADLESS']
require 'headless'
headless = Headless.new
headless.start
at_exit do
headless.destroy
end
end
并运行
cucumber ENV=HEADLESS features/test.feature:25
我收到以下错误。
end of file reached (EOFError)
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/net/protocol.rb:141:in `read_nonblock'
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/net/protocol.rb:141:in `rbuf_fill'
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/net/protocol.rb:122:in `readuntil'
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/net/protocol.rb:132:in `readline'
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/net/http.rb:2562:in `read_status_line'
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/net/http.rb:2551:in `read_new'
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/net/http.rb:1319:in `block in transport_request'
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/net/http.rb:1316:in `catch'
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/net/http.rb:1316:in `transport_request'
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/net/http.rb:1293:in `request'
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/net/http.rb:1286:in `block in request'
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/net/http.rb:745:in `start'
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/net/http.rb:1284:in `request'
/var/lib/jenkins/.rvm/gems/ruby-1.9.3-p286@cucumber/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/http/default.rb:82:in `response_for'
/var/lib/jenkins/.rvm/gems/ruby-1.9.3-p286@cucumber/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/http/default.rb:38:in `request'
/var/lib/jenkins/.rvm/gems/ruby-1.9.3-p286@cucumber/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/http/common.rb:40:in `call'
/var/lib/jenkins/.rvm/gems/ruby-1.9.3-p286@cucumber/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/bridge.rb:598:in `raw_execute'
/var/lib/jenkins/.rvm/gems/ruby-1.9.3-p286@cucumber/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/bridge.rb:92:in `create_session'
/var/lib/jenkins/.rvm/gems/ruby-1.9.3-p286@cucumber/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/bridge.rb:68:in `initialize'
/var/lib/jenkins/.rvm/gems/ruby-1.9.3-p286@cucumber/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/chrome/bridge.rb:29:in `initialize'
/var/lib/jenkins/.rvm/gems/ruby-1.9.3-p286@cucumber/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/common/driver.rb:37:in `new'
/var/lib/jenkins/.rvm/gems/ruby-1.9.3-p286@cucumber/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/common/driver.rb:37:in `for'
/var/lib/jenkins/.rvm/gems/ruby-1.9.3-p286@cucumber/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver.rb:65:in `for'
/var/lib/jenkins/.rvm/gems/ruby-1.9.3-p286@cucumber/gems/watir-webdriver-0.6.1/lib/watir-webdriver/browser.rb:35:in `initialize'
/var/lib/jenkins/automation/features/support/hooks.rb:9:in `new'
/var/lib/jenkins/automation/features/support/hooks.rb:9:in `Before'
Given I am on the login page
And login as a blogger
Then I must see the text "Blog List"
undefined method `driver' for nil:NilClass (NoMethodError)
/var/lib/jenkins/automation/features/support/hooks.rb:27:in `After'
undefined method `close' for nil:NilClass (NoMethodError)
/var/lib/jenkins/automation/features/support/hooks.rb:17:in `After'
任何帮助将不胜感激。谢谢!!