nil:NilClass (NoMethodError) arch linux 中的水豚、selenium-webdriver 和 firefox 的未定义方法“删除”

undefined method `delete' for nil:NilClass (NoMethodError) capybara, selenium-webdriver and firefox in arch linux

我写这篇文章是因为我在使用黄瓜和水豚进行测试时遇到了问题运行。我正在使用带硒驱动程序的水豚框架。这是我的 env.rb

require 'capybara/cucumber'

Capybara.default_driver = :selenium

这是我的 steps.rb 文件

Given (/^I am on Youtube$/) do 
  visit "http://www.youtube.com"
end

When (/^I fill in "([^"]*)" with "([^"]*)"$/) do |field, value|
  fill_in(field, :with => value)
end

When (/^I press "([^"]*)"$/) do |button|
  click_button(button)
end

Then (/^I should see "([^"]*)"$/) do |text|
  page.should have_content(text)
end

这是我获得的输出。我尝试在 Mac 系统中用 Cucumber 执行同一个文件,它可以工作。我正在使用内核版本为 4.10.6-1-ARCH #1 SMP PREEMPT

的 Arch Linux (antergos)
Feature: YouTube has a search function.

  Scenario: Search for a term                                    # features/youtube_search.feature:3
    Given I am on Youtube                                        # features/step_definitions/youtube_search_steps.rb:1
      undefined method `delete' for nil:NilClass (NoMethodError)
      ./features/step_definitions/youtube_search_steps.rb:2:in `/^I am on Youtube$/'
      features/youtube_search.feature:4:in `Given I am on Youtube'
    When I fill in "search_query" with "text adventure"          # features/step_definitions/youtube_search_steps.rb:5
    And I press "search-btn"                                     # features/step_definitions/youtube_search_steps.rb:9
    Then I should see "GET LAMP: The Text Adventure Documentary" # features/step_definitions/youtube_search_steps.rb:13

Failing Scenarios:
cucumber features/youtube_search.feature:3 # Scenario: Search for a term

1 scenario (1 failed)
4 steps (1 failed, 3 skipped)
0m1.898s

注意: 当我 运行 cucumber 命令时,一个新的 firefox window 打开了,但是我在终端和测试中看到了提到的错误不继续了。

提前谢谢大家。

我遇到了这个问题。当 selenium-webdriver 和 Firefox 版本不匹配时会发生这种情况。由于 Firefox 经常更新,您会不时收到此错误。如果你更新你的 selenium-web 它应该可以解决这个问题。它对我有用。