黄瓜无头xvfb的Ubuntu的(Cucumber headless xvfb ubuntu)

2019-08-03 01:45发布

我试图建立一个詹金斯建立在Amazon EC2服务器。 我打算在无头的模式下运行我的黄瓜测试套件。 我是能够成功地在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'

任何帮助将不胜感激。 谢谢!!

Answer 1:

问题是在命令行参数的env

cucumber HEADLESS=true features/test.feature:25 

代替

cucumber ENV=HEADLESS features/test.feature:25


文章来源: Cucumber headless xvfb ubuntu