Joe12
Joe12

Reputation: 69

undefined method `visit' for #<Object (NoMethodError) capybara rspec

I am getting an error undefined method `visit' for

require "selenium-webdriver"
require "rubygems"
require "cucumber"
require "capybara"
require 'capybara/rspec/matchers'
Capybara.default_driver = :selenium

Upvotes: 1

Views: 956

Answers (2)

Thomas Walpole
Thomas Walpole

Reputation: 49950

As documented you need to require 'capybara/cucumber' to include the capybara dsl methods into cucumber tests. If you have an issue with doing that you'd need to call all the methods on current_session like Capybara.current_session.visit('/').

Upvotes: 1

max pleaner
max pleaner

Reputation: 26788

From the Capybara docs here there's a section using the DSL elsewhere

You can use this code:

require 'capybara/dsl'

# putting this at the top level will make capybara methods available everywhere
# you can put it in a module if you want to, well, modularize ...
include Capybara::DSL

Upvotes: 1

Related Questions