0

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

5
  • 1
    Use code format for better formatting your question. Commented Jan 23, 2019 at 6:53
  • Are you getting XML output first ? Commented Jan 23, 2019 at 7:39
  • 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?? Commented Jan 23, 2019 at 9:01
  • @Thomas This happens only when i add, include Capybara::DSL in the env.rb file in cucumber tests. Commented Jan 29, 2019 at 9:32
  • @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. Commented Jan 29, 2019 at 9:35

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks @Thomas Walpole, When i do World(Capybara::DSL), I cant use Capybara's methods inside my test scripts. When i try to use page method of capybara's, I am getting error like page method is not found, but when i use include Capybara::DSL, page method is getting recognised and i get my scripts running smooth. Any idea on why i am facing this behaviour.
@NareshSekar That really all depends on how your project is set up. All your scenarios should be run in a World so Capybaras methods should be available there, read docs.cucumber.io/cucumber/state/#world-object. I don't know what your World objects are. Are the "test scripts" actually cucumber scenarios? Note: you can always call Capybara.current_session which is what page does.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.