Ruby 第一个测试套件因allure rspec而失败

Ruby 第一个测试套件因allure rspec而失败,ruby,rspec,selenium-webdriver,allure,Ruby,Rspec,Selenium Webdriver,Allure,我正在努力将allure集成到我的测试中,但是遇到了一个问题,第一个测试套件失败了,并且在套件中的每个测试中都返回了一个未定义的方法“find_element”,用于nil:NilClass error。当我不使用allure时,测试按预期运行,无论运行哪个套件,都会发生同样的情况 我已经研究过了,我的规范助手中的前后钩子似乎没有在失败的测试中使用。你知道这是什么原因吗 require 'rspec' require 'selenium-webdriver' require 'allure-rs

我正在努力将allure集成到我的测试中,但是遇到了一个问题,第一个测试套件失败了,并且在套件中的每个测试中都返回了一个未定义的方法“find_element”,用于nil:NilClass error。当我不使用allure时,测试按预期运行,无论运行哪个套件,都会发生同样的情况

我已经研究过了,我的规范助手中的前后钩子似乎没有在失败的测试中使用。你知道这是什么原因吗

require 'rspec'
require 'selenium-webdriver'
require 'allure-rspec'
require 'nokogiri'
require 'uuid'
require 'pathname'

RSpec.configure do |c|


c.include AllureRSpec::Adaptor


c.expect_with :rspec do |c|
    ### Enable both should and expect syntax ###
    c.syntax = [:should, :expect]
end

c.before(:all) do
    #Start the Phantom-js driver before running any headless tests
    case ENV['browser']
    when 'headless'
        ## Run in command line before a headless test: phantomjs --webdriver=8001
        system('start cmd /k phantomjs --webdriver=8001')
        sleep 3
    end
end

c.before(:each) do  
    #Find the browser to the used and set the driver to the appropriate one
    case ENV['browser']
    when 'chrome'
        @driver = Selenium::WebDriver.for :chrome
        #@driver = Selenium::WebDriver.for(:remote, url: 'http://localhost:5555/wd/hub', desired_capabilities: :chrome)
    when 'ie'
        @driver = Selenium::WebDriver.for :internet_explorer
        #@driver = Selenium::WebDriver.for(:remote, url: 'http://localhost:5555/wd/hub', desired_capabilities: :ie)
    when 'firefox'
        @driver = Selenium::WebDriver.for :firefox
        #@driver = Selenium::WebDriver.for(:remote, url: 'http://localhost:5555/wd/hub', desired_capabilities: :firefox)
    when 'headless'
        @driver = Selenium::WebDriver.for :remote, url: 'http://localhost:8001'
    end
    #Maximize the browser
    @driver.manage.window.maximize
    @driver.get ENV['base_url']
end

c.after(:each) do |c|
    #Takes a screen shot if an exception is thrown and attaches it to the allure XML when running Rake tests
    if c.exception != nil
        $failure = true

            c.attach_file("screenshot", File.new(@driver.save_screenshot(File.join(Dir.pwd, "test_reports/allure/#{UUID.new.generate}.png"))))

    end 
    @driver.quit
end 

end

AllureRSpec.configure do |c|
   #Outputs the Allure XML
   c.output_dir = "test_reports/allure"
end

您使用的是诱惑和rspec的哪个版本?我现在使用的是3.2。您能提供一个示例项目来重现这个问题吗?