Watir:nil:NilClass的未定义方法'bridge'(NoMethodError)

时间:2019-04-02 10:58:43

标签: ruby cucumber watir

每当我运行功能时,都会出现此错误:

$ cucumber features/adopt_puppies.feature

Cucumber.yml
default: BROWSER=chrome

Using the default profile...
Feature: Verify total puppies available to buy on website

    Given I am on puppies website       
    # features/step_definitions/adopt_puppies.rb:3
      undefined method `bridge' for nil:NilClass (NoMethodError)
      ./features/step_definitions/adopt_puppies_helper.rb:4:in `goto_website_homepage'
      ./features/step_definitions/adopt_puppies.rb:4:in `/^I\ am\ on\ puppies\ website$/'
      features/adopt_puppies.feature:4:in `Given I am on puppies website'

要解决此问题,我已经降级了
cucumber gem to 2.99.0selenium-webdriver gem to 3.5.0
但仍然会出现相同的错误。

我在做什么错?

更新: 在添加hooksenv文件之后,此问题已得到解决,但现在又出现了另一个(类似)错误。如果我在cucumber.yml中使用以下行,即我想使用pretty-face gem (version 0.10.3)

default: BROWSER=chrome --no-source --color --format PrettyFace::Formatter::Html --out results/index.html

错误是一样的,只是要求其他文件可用:

C:/Ruby24-x64/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:54:in `require': `require "watir-webdriver"` is deprecated. Please, use `require "watir"`.
cannot load such file -- cucumber/ast/scenario
Error creating formatter: PrettyFace::Formatter::Html (LoadError)
C:/Ruby24-x64/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:54:in `require'
C:/Ruby24-x64/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:54:in `require'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/pretty_face-0.10.3/lib/pretty_face/formatter/html.rb:5:in `<top (required)>'
C:/Ruby24-x64/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:130:in `require'
C:/Ruby24-x64/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:130:in `rescue in require'
C:/Ruby24-x64/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:34:in `require'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-3.1.2/lib/cucumber/constantize.rb:19:in `rescue in constantize'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-3.1.2/lib/cucumber/constantize.rb:8:in `constantize'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-3.1.2/lib/cucumber/configuration.rb:211:in `formatter_class'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-3.1.2/lib/cucumber/configuration.rb:196:in `block in formatter_factories'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-3.1.2/lib/cucumber/configuration.rb:194:in `map'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-3.1.2/lib/cucumber/configuration.rb:194:in `formatter_factories'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-3.1.2/lib/cucumber/runtime.rb:197:in `formatters'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-3.1.2/lib/cucumber/runtime.rb:182:in `report'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-3.1.2/lib/cucumber/runtime.rb:72:in `run!'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-3.1.2/lib/cucumber/cli/main.rb:34:in `execute!'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-3.1.2/bin/cucumber:9:in `<top (required)>'
C:/Ruby24-x64/bin/cucumber:23:in `load'
C:/Ruby24-x64/bin/cucumber:23:in `<main>'

0 个答案:

没有答案