0
votes

I am trying to run the cucumber test cases along with capybara and selenium webdriver. While running I am getting the following error even if all the test cases are passed. As a result, cucumber jenkins job is getting failed. When I try to open the allure report, it is blank.

Can any one help me out from this ?

log trace:

3 scenarios (0 failed, 3 passed) 12 steps (0 failed, 12 passed) 1m8.278s

wrong number of arguments (given 1, expected 0) (ArgumentError) /Users/user/.rvm/gems/ruby-2.6.0/gems/capybara-3.12.0/lib/capybara/node/document.rb:31:in title' /Users/user/.rvm/gems/ruby-2.6.0/gems/capybara-3.12.0/lib/capybara/session.rb:738:in block (2 levels) in class:Session' /Users/user/.rvm/gems/ruby-2.6.0/gems/capybara-3.12.0/lib/capybara/dsl.rb:51:in block (2 levels) in ' /Users/user/.rvm/gems/ruby-2.6.0/gems/allure-ruby-adaptor-api-0.7.2/lib/allure-ruby-adaptor-api/builder.rb:128:in block (3 levels) in build!' /Users/user/.rvm/gems/ruby-2.6.0/gems/nokogiri-1.10.1/lib/nokogiri/xml/builder.rb:391:in insert' /Users/user/.rvm/gems/ruby-2.6.0/gems/nokogiri-1.10.1/lib/nokogiri/xml/builder.rb:375:in method_missing' /Users/user/.rvm/gems/ruby-2.6.0/gems/allure-ruby-adaptor-api-0.7.2/lib/allure-ruby-adaptor-api/builder.rb:126:in block (2 levels) in build!' /Users/user/.rvm/gems/ruby-2.6.0/gems/nokogiri-1.10.1/lib/nokogiri/xml/builder.rb:293:in initialize' /Users/user/.rvm/gems/ruby-2.6.0/gems/allure-ruby-adaptor-api-0.7.2/lib/allure-ruby-adaptor-api/builder.rb:125:in new' /Users/user/.rvm/gems/ruby-2.6.0/gems/allure-ruby-adaptor-api-0.7.2/lib/allure-ruby-adaptor-api/builder.rb:125:in block in build!' /Users/user/.rvm/gems/ruby-2.6.0/gems/allure-ruby-adaptor-api-0.7.2/lib/allure-ruby-adaptor-api/builder.rb:124:in each' /Users/user/.rvm/gems/ruby-2.6.0/gems/allure-ruby-adaptor-api-0.7.2/lib/allure-ruby-adaptor-api/builder.rb:124:in build!' /Users/user/.rvm/gems/ruby-2.6.0/gems/allure-cucumber-0.6.1/lib/allure-cucumber/formatter.rb:144:in after_features' /Users/user/.rvm/gems/ruby-2.6.0/gems/cucumber-3.1.2/lib/cucumber/formatter/ignore_missing_messages.rb:11:in method_missing' /Users/user/.rvm/gems/ruby-2.6.0/gems/cucumber-3.1.2/lib/cucumber/formatter/legacy_api/adapter.rb:136:in after' /Users/user/.rvm/gems/ruby-2.6.0/gems/cucumber-3.1.2/lib/cucumber/formatter/legacy_api/adapter.rb:41:in block in initialize' /Users/user/.rvm/gems/ruby-2.6.0/gems/cucumber-core-3.2.1/lib/cucumber/core/event_bus.rb:34:in block in broadcast' /Users/user/.rvm/gems/ruby-2.6.0/gems/cucumber-core-3.2.1/lib/cucumber/core/event_bus.rb:34:in each' /Users/user/.rvm/gems/ruby-2.6.0/gems/cucumber-core-3.2.1/lib/cucumber/core/event_bus.rb:34:in broadcast' /Users/user/.rvm/gems/ruby-2.6.0/gems/cucumber-core-3.2.1/lib/cucumber/core/event_bus.rb:40:in method_missing' /Users/user/.rvm/gems/ruby-2.6.0/gems/cucumber-3.1.2/lib/cucumber/configuration.rb:33:in notify' /Users/user/.rvm/gems/ruby-2.6.0/gems/cucumber-3.1.2/lib/cucumber/runtime.rb:76:in run!' /Users/user/.rvm/gems/ruby-2.6.0/gems/cucumber-3.1.2/lib/cucumber/cli/main.rb:34:in execute!' /Users/user/.rvm/gems/ruby-2.6.0/gems/cucumber-3.1.2/bin/cucumber:9:in ' /Users/user/.rvm/gems/ruby-2.6.0/bin/cucumber:23:in load' /Users/user/.rvm/gems/ruby-2.6.0/bin/cucumber:23:in

' /Users/user/.rvm/gems/ruby-2.6.0/bin/ruby_executable_hooks:24:in eval' /Users/user/.rvm/gems/ruby-2.6.0/bin/ruby_executable_hooks:24:in ' Took 70 seconds (1:10) cucumbers Failed

1
Use code format for better formatting your question.Harsh Patel
Are you getting XML output first ?Rajagopalan
Line 128 of /Users/user/.rvm/gems/ruby-2.6.0/gems/allure-ruby-adaptor-api-0.7.2/lib/allure-ruby-adaptor-api/builder.rb is calling Capybaras title method instead of the one it expects. You aren't including Capybara::DSL in the global scope are you??Thomas Walpole
@Thomas This happens only when i add, include Capybara::DSL in the env.rb file in cucumber tests.Naresh Sekar
@NareshSekar Ok - so you are including it -- where are you including it to? Edit your question and add the relevant section of env.rb. I'm guessing you're seeing a message like "including Capybara::DSL in the global scope is not recommended!" which should have been your first clue.Thomas Walpole

1 Answers

1
votes

The problem here is that you are including Capybara::DSL in the global scope. Any relatively modern version of Capybara will print a warning to the console like "including Capybara::DSL in the global scope is not recommended!" specifically because it will have all sorts of strange side effects. This is because when you just do

include Capybara::DSL

outside of any classes or modules you end up including all of Capybaras methods on every object in your project. That's not what you want. It's impossible to say exactly what you need to put where without looking at your project, but assuming you have a normal project you probably want to put

World(Capybara::DSL)
World(Capybara::RSpecMatchers)

in your env.rb, or just require 'capybara/cucumber' like instructed - https://github.com/teamcapybara/capybara#using-capybara-with-cucumber - which will get things set up correctly.